Reputation: 295
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.
Upvotes: 1
Views: 983
Reputation: 6271
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';
Upvotes: 5