Ignoring / skipping known or all subordinated tags with XPath
I am using XPath with Hpple / libxml2 for parsing HTML in iOS / iPhone OS. I now want to ignore开发者_运维知识库 a certain tag like the bold tag <b>
when parsing the document:
For instance from the code
<div>foo<b>bar</b></div>
the strings "foo" and "bar" should be selected and concatenated resulting in "foobar".
It appeared to me after viewing related requests that they possibly would not solve this issue but it's absolutely possible that I am wrong. If so, please let me know and give an example using the example above.
Thank you.
Use:
string(/*)
When evaluated against the provided XML document:
<div>foo<b>bar</b></div>
the wanted, correct result is produced:
foobar
Explanation:
As per the XPath 1.0 W3C specification:
"The string-value of an element node is the concatenation of the string-values of all text node descendants of the element node in document order"
精彩评论