Re: string value of every element
- From: Joe Kesselman <keshlam.cat.nospam@xxxxxxxxxxx>
- Date: Mon, 04 May 2009 02:08:09 GMT
Phantom wrote:
Simple question that's driving me freakin mad.
Hard to answer without seeing your code -- are you working with XPath, or with the DOM, or with one of the other APIs/tools? Are you sure that whatever being returned doesn't need to be iterated over to retrieve the rest of the content?
In XPath, the string value of the fruits element is normally going to be all text contained within it -- which will include the newlines:
"
apple
banana
pear
"
If you had asked for the string value of /fruits/fruit, you would get "apple", since the string value of a multiple-node result is the string value of the first match. You'd need to iterate through the results to gather the other values, and of course concatenating them into a string would be your responsibility.
If you're using the simple DOM operations, elements don't have a string value; you must navigate the tree and gather the values. The DOM's XPath support, if present in your DOM, has an operation which will do the gather-and-concatenate operation -- but again, it's going to include the newlines.
.
- References:
- string value of every element
- From: Phantom
- string value of every element
- Prev by Date: string value of every element
- Next by Date: Re: string value of every element
- Previous by thread: string value of every element
- Next by thread: Re: string value of every element
- Index(es):
Relevant Pages
|