user592704
user592704

Reputation: 3704

GWT - XML parser - cannot read tag

I just faced a problem with gwt xml parser

the thing is ...

I have xml like

<?xml version="1.0" ?>
<A>
<B>
<C>C1</C>
<C>C2</C>
<C>C3</C>
</B>
<B></B>
</A>
<A>
</A>

and gwt code...

Document document = XMLParser.parse(xml);
NodeList nl= document.getElementsByTagName("A");
Window.alert("threads length = "+nl.getLength());

for some reason nl.getLength() returns 0 that means there is no A tag :( Why that may happen and how to get xml structure correctly?

Any useful comment is appreciated

Upvotes: 1

Views: 246

Answers (1)

user166390
user166390

Reputation:

So to close this question...

Strictly speaking, an XML document can only contain one top-level (or "root") element node. That has two.

XMLParser will apparently "not work correctly" for this malformed XML input <-- please feel free to add details here or in a comment :)

Happy coding.

Upvotes: 1

Related Questions