On Jun 3, 2004, at 11:02 AM, Song Li wrote:
Hi,
I have an XML file with the format looks like: =================================== <relation entry1="43" entry2="48" type="ECrel"> <subtype name="compound" value="88"/> </relation> ===================================
I want to extract the "value" under the node "subtype" by using DOM, I've tried two methods but neither return a correct result:
method 1: get a DOMnode(let's call it nd) points to "relation", then call "nd2 = nd->getFirstChild();". The problem is that this nd2 has the type "TEXT NODE", so I can't use "getAttributes", and getTextContent() doesn't work as well.
You'll want to move on to the next node. The text node that you're looking at is the whitespace (probably tab) in the line before the <subtype> tag. You don't want to blindly assume that when you have a node that its' children are what you think they are - you need to check the tag names to make sure that they are indeed what you're looking for. Or, you can validate the document and have the parser remove the bonus text nodes.
-- Nick
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]