I am new to XML, and DOM. I guess I need to use DOM API to find go through every non-text nodes once, and output the node name.
say I got this example XML from W3C
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
<page pagenumber="550"/>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
<page pagenumber="500"/>
</book>
</bookstore>
I need to find node such as <page pagenumber="500" /> which is a non-text node
How can I do that? seduo-code would be fine too. Thanks
can I say
while (x.nodeValue == NULL) {
read the next node ?
}
I guess I should make myself clear, no assumption on any docuemnts. This should work on all XML as long as there is a non-text node. I guess this should be done in the order from top-down and from left to right for every nodes. :(
XPATH ="//*[not(text())]"
Will select all nodes which are non-text node.
Here in the given example: bookstore and book are also non-text nodes as they does not have any text of their own, though their children do have text.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With