I am analyzing an XML file using NSXMLParser
, which works great but sometimes gives me inaccurate results.
For example, I get this URL:
http://www.thehungersite.com/clickToGive/home.faces;jsessionid=01F974DC9E276DA587AE299175EDF4F4.ctgProd02?siteId=4&开发者_如何转开发link=ctg_trs_home_from_ths_home_sitenav
but NSXMLParser
outputs:
http://www.thehungersite.com/clickToGive/home.faces;jsessionid=01F974DC9E276DA587AE299175EDF4F4.ctgProd02?siteId=4&link=ctg_trs_home_from_ths_home_sitenav
For some reason, it ignored the #38;
part of the string - how can I get this back? Assuming this was HTML encoding I have tried stringByAddingPercentEscapesUsingEncoding:
but that will not work.
Any ideas?
XML uses the same character reference encoding mechanism as HTML (although it has only 5 predefined named entities, as opposed to the huge number defined for HTML). &
is an encoding for the &
character.
Perhaps the top answer to this question might help: Objective-C: How to replace HTML entities?
It's basically a category to NSString someone made that offers both encoding and decoding of HTML entities in NSString.
You're using the ISO standard. Try either using %26 or by using url encoding.
精彩评论