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

  • Home
  • SEARCH
  • 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 8374443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:55:27+00:00 2026-06-09T14:55:27+00:00

I am using following XPath to pick some data from an html page. The

  • 0

I am using following XPath to pick some data from an html page. The value I am trying to pick has some spaces in between:

example=value1    value2       value3

My XPath expression is picking the value but removes extra spaces between text like this:

value1 value2 value3

How do I make sure that extra spaces are not removed?

My xpath:

//*something/div/input[1]/@value

Sample HTML from where I am picking value:

<input type="radio" name='radio1' value="R92392   12132                           sdlasldkaskl                  " id='some' >

Note that I am getting the value as R92392 12132 sdlasldkaskl. But I want the spaces between text to be preserved.

  • 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-09T14:55:28+00:00Added an answer on June 9, 2026 at 2:55 pm

    My XPath engine doesn’t remove the whitespaces so it must be due to a PHP setting. I’m not exactly sure about your situation as you didn’t provide much code but the following might work you:

    $doc->preserveWhiteSpace = true; // This setting should fix it
    $doc->Load('document.xml');
    $xpath = new DOMXPath($doc);
    $query = '//div/input[1]/@value';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to identify duplicate serial numbers from the following xml using XPath
I am trying to parse review from this page: http://www.amazon.co.uk/product-reviews/B00143ZBHY Using following approach: Code
I'm scraping values from HTML pages using XPath inside of a java program to
I am using Xpath in Ruby with following statement. print XPath.first(Document.new(html),//tr[@id='ctl00_c1_rr_ci_trAdd']//td[2]) The Query return
I'm trying to convert the following xpath to find the same element, but using
I'm currently using XPath to get some information from a podcast feed using Java
I am using the following code to query some XML with XPath I get
I have been using the following xpath selection in xpath 1.0 <xsl:variable name=id><xsl:value-of select=./@id
I have the following XPATH line: //det[@nItem=1]/prod/cProd That successfully selects the desired node using
i am using the following nested xpath query $xpath->query('//ul[@id=ref_1000]/li[not(strong)][//span[@class=refinementLink]]'); what i want is search

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.