Ampersand in XML data not allowing to load xml
i am using a web service which is retrieving me xml, which contains lots of url. i am using below code to load it:
XmlDocument xdoc = new XmlDocument();
xdoc.Load(fileName.Trim());
its not able to load my xml if any ampersand exists in any element's content. my xml is like:
<media:thumbnail url="http://someurl/player/mezzanine/image.php?w=124&h=99&path=ndtv/a79d98c3030c041e0033105943c1b668_mezzn.jpg&hash=23991c2513a8e359d120840e6f897d4d" width="124" height="70" />
<media:fullimage url="" width="350" height="196" />
NOTE: i can't do changes in web service, as i am getting this from other provider. please help me. Thanks
i am getting this exception:
System.Xml.XmlException: '=' is an unexpected token. The expected token is ';'. Line 753, position 89.
on this row
<media:thumbnail url="http://someurl/player/mezzanine/image.php?w=124&h=99&path=ndtv/a79d98c3030c041e0033105943c1b668_mezzn.jpg&hash=23991c2513a8e359d120840e6f897d4d" width="124" height="70" />开发者_JAVA技巧
If you can't get the provider to fix their "XML", then the easiest thing to do is run it through a utility, such as Tidy .NET, which attempt to compensate for those sorts of issues and return a well-formed XML file that you can process.
Replace each &
in url
with &
Replacing &
with &
fixes this for me for the IE client-side XML parser which I assume is the same library. Interestingly, FF didn't have issues with the & character between double-quotes.
精彩评论