Can't load XML file in asp.net -
when run code:
@inherits umbraco.web.macros.partialviewmacropage @using system.xml; @{ xmldocument vxmldocument = new xmldocument(); string vurl = "https://www.herefordshire.gov.uk/info/200142/planning_services/planning_application_search/rss?search-term=brilley&search-service=search&search-source=the%20keyword&search-item=brilley"; vxmldocument.load(vurl); xmlelement vrss = vxmldocument.documentelement; xmlnode vchannel = vrss.firstchild; xmlnodelist vchildnodes = vchannel.childnodes; foreach (xmlnode vxmlnode in vchildnodes) { if (vxmlnode.name == "item") { <div> <a href="@vxmlnode["link"].innertext" target="_blank">@vxmlnode["title"].innertext</a> </div> } } }
at
vxmldocument.load(vurl);
i error:
the underlying connection closed: unexpected error occurred on send.
the link i'm using display xml file, can see. if make vurl = http://ubeumbraco.co.uk/brilleyapplications.xml
, works fine.
what doing wrong?
your appreciated.
thanking in anticipation.
roger
the url provide not xml file, xmldocument.load
expects. web service returns response in xml format.
you can first download response string, call xmldocument.loadxml
parse string xmldocument
instance.
using(var wc = new webclient()) { string xmlstr = wc.downloadstring(vurl); vxmldocument.loadxml(xmlstr); }
Comments
Post a Comment