Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: string value of every element

From: Joe Kesselman <keshlam.cat.nospam@-------.--->
To: NULL
Date: 5/4/2009 2:08:00 AM
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.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent