This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi, I am getting an xml String that has new lines and empty spaces between nodes. So for example if I am on root and I am saying root.getFirstChild() I am getting the text node that is new line and spaces instead of the real child. I tried normalize on the root but it didn't help. What do I do?
Stop calling getFirstChild() if you don't want the first child. Do something else which gets the child you are interested in.
That could involve getting all the children and examining them, or calling getElementsByTagName, or using XPath, or something else.
Edit: and don't call the child you are interested in the "real" child. All of them are real. Calling it that just leads you into denial. The structure of the document is what it is. Choose what you want and ignore what you don't want. [ December 11, 2008: Message edited by: Paul Clapham ]
Joined: Sep 25, 2008
not helpful. at the point of parsing I don't know any paths or names. I just know I need the "real" child