I'm fetching the value of an XML entity in an libxml2 SAX parser similarly to how the ansewr to this question suggests. Specifically, my code looks like so (attributes[i].value
is *xmlChar
):
int valueLength = (int) (attributes[i].end - attributes[i].value);
value = [[[NSString alloc] initWithBytes:attributes[i].value
length:valueLength
encoding:NSUTF8StringEncoding
] autorelease];
However, for some reason, when the attribute value (a URL in this case) has the entity &
in the original XML, the value I get has &
.
Say what?
How do I get libxml2 to decode attribute entities (it seems to do it fine for text node entities), so that I just get &
?