Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8466813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:27:10+00:00 2026-06-10T15:27:10+00:00

How can I get just the currency value from a string bellow using php

  • 0

How can I get just the currency value from a string bellow using php xpath?

<div class="detalheDir2">
<div class="preco">
R$
<script type="text/javascript">document.write(aZ427014992694557())</script>
24,90
</div>
</div>

I want to get just 24,90

I’m using the query

$xpath->query("descendant::div[@class='detalheDir2']/div[@class='preco']/text()", $child);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:27:12+00:00Added an answer on June 10, 2026 at 3:27 pm

    If your desired text node is always in this position, you can use indexing like:

    //div[@class='detalheDir2']/div[@class='preco']/text()[2]
    

    If its always after the a <script> tag you can write:

    //div[@class='detalheDir2']/div[@class='preco']/script/following-sibling::text()
    

    If its always the last text node you can write

    //div[@class='detalheDir2']/div[@class='preco']/text()[last()]
    

    Maybe the fact that it contains a , could be the key:

    //div[@class='detalheDir2']/div[@class='preco']/text()[contains(., ',')]
    

    All of these work for your example, however variance in your input will make any of these break.

    If you only know that it’s there somewhere among the text nodes and only the format sets it apart from the others, you might be better off selecting all the text nodes and iterate through them, and matching with regexps on textContent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just can't get the ajax service to work. A simple class to $.get(http://google.com)
How can I get the title tag from the s:variant block below using simple
I am trying to get the localized currency symbol using the NumberFormatter in PHP's
I can get all <a> tags using PHP's DOMDocument, but how can I get
How can I get just the table comment from a mysql table? I tried
Given this variable in tcsh: set i = ~/foo/bar.c how can I get just
I'm sure it's pretty easy, but I just can get it to work. I
I am just wondering how i can get the error causing LoginUser function to
I was just wondering how I can get a single tap to undo the
I just installed Nginx listening on 8083 I can get a HTTP response when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.