开发者

How to read nested XML using xDocument in Silver light?

开发者 https://www.devze.com 2022-12-24 02:35 出处:网络
Hi currently I have a nested XMl , having the following Structure : <?xml version=\"1.0\" encoding=\"utf-8\" ?>

Hi currently I have a nested XMl , having the following Structure :

<?xml version="1.0" encoding="utf-8" ?> 
<Response>
    <Result>
        <item id="something" />
        <price na="something" />
        开发者_JAVA百科<?xml version="1.0" encoding="UTF-8" ?>
        <DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/" xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/">
    </Result>
    <NumberReturned>10</NumberReturned>
    <TotalMatches>10</TotalMatches>
</Response> 

Any help on how to read this using Xdocument or XMLReader will be really helpfull.

Thanks, Subhendu


XDocument and XmlReader are both XML parsers that expect a properly formed XML as input. What you have shown is not a XML file. So the first task would be to extract the nested XML and as this is not valid XML you cannot rely on any parser to do this job. You'll need to resort to string manipulation and or regular expressions.

My suggestion would be to fix the procedure generating this invalid XML in the first place. Another suggestion is to never generate a XML file manually but use an appropriate tool for this (XmlWriter, XDocument, ...)

0

精彩评论

暂无评论...
验证码 换一张
取 消