First problem is that I expect 5 nodes not 10. Where is: "#text" coming from?
I also do not understand why I have to say:
Node nextNode = root.getFirstChild() Element docNode = nextNode.getNextSibling()//docNode should be first child
"DocumentProperties" should be the first child. But if I rely on that, I again get a node name of: "#text" as well.
Thanks.
Tom
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
If you examine the contents of the "#text" nodes, you'll see that they represent the white space between the elements (which is significant in XML).
If you use JAXP for parsing, have a look at the DocumentBuilderFactory.setIgnoringElementContentWhitespace method, which suppresses the creation of nodes containing only white space (if I understand this page correctly).
In the future, please use a more descriptive subject line. "Why is this happening?" says nothing about the problem at hand. [ August 04, 2006: Message edited by: Ulf Dittmer ]
Originally posted by Ulf Dittmer: If you use JAXP for parsing, have a look at the DocumentBuilderFactory.setIgnoringElementContentWhitespace method, which suppresses the creation of nodes containing only white space (if I understand this page correctly).
The API documentation for the method says this:
Note that only whitespace which is directly contained within element content that has an element only content model (see XML Rec 3.2.1) will be eliminated. Due to reliance on the content model this setting requires the parser to be in validating mode.
I believe that jargon about "element only content model" means the document has to be described by a DTD or a schema, at least.
Tom Sullivan
Ranch Hand
Joined: Dec 20, 2005
Posts: 72
posted
0
Thanks very much for the help. I'll go get the MS schema and see if that solves the problem.