3

I'm using kXML2 on a legacy JavaME project. I'm receiving an XML where some attributes contain encoded entites. When I retrieve that attribute value with the call:

parser.getAttributeValue

It throws an Exception:

XmlPullParserException: unresolved

I have downloaded the last version of this parser, but it still shows this behavior.

If I remove the problematic line from XML, then there are no errors.

Mister Smith
  • 27,417
  • 21
  • 110
  • 193

1 Answers1

2

Ok, here is what is happening:

The parser must decode entities in attributes, unless you set this property:

parser.setFeature(KXmlParser.FEATURE_PROCESS_DOCDECL, true);

But this implementation throws an exception when that line is called. Allright, so I debugged into the parser source code and I found out that this pull-parser implementation has trouble with entities that are not very common.

So I must inflate the parser entity replacement map with my own "odd" entities for it to work, like this:

parser.defineEntityReplacementText("Ntilde", "Ñ");

And then everything works fine.

Mister Smith
  • 27,417
  • 21
  • 110
  • 193