Hi!
I have a problem.
I'm trying to parse the return values from a XML web API, and the XML is a bit misformed:
<xmlroot>
<abc:whatever>value</abc:whatever>
</xmlroot>
This gives me an exception when trying to parse it with Xerces:
The prefix "abc" for element "abc:whatever" is not bound.
Now, I can't insert a namespace declaration into the document, since, well, it isn't parsed. I can't make the API change its output since it's a third party and I'm tight on time. And I can't prepend XML.
Is there a way to disable namespace handling in Xerces 2? To make it just view "abc:whatever" as a name?
-
Working around some malformed XML (1 messages)
- Posted by: Viktor Lundstr??m
- Posted on: December 22 2004 05:24 EST
Threaded Messages (1)
- Working around some malformed XML by Artem Yegorov on January 07 2005 14:53 EST
-
Working around some malformed XML[ Go to top ]
- Posted by: Artem Yegorov
- Posted on: January 07 2005 14:53 EST
- in response to Viktor Lundstr??m
If you have access to the non-parsed content, just put the namespace declaration manually before parsing the XML.
Like:
StirngBuffer xml = new StringBuffer(xmlText);
xml.insert(xmlText.indexOf(">")," xmlns:abc=\"some bogus uri\"");
That's given if, again, you have access to your xml content and the structure is always like the one you've specified, in case of possible declaration, you can rip it out before inserting the namepsace(s).
Sincerely,
Artem D. Yegorov
http://www.activexml.org