Search code examples
c#xmlweb-serviceshtml-agility-packazure-worker-roles

XML Parsing with HtmlAgilityPack


I'm parsing xml with HtmlAgilityPack on WebService worker role, but there is something wrong. When I select childnode "link" get empty char. the xml like :

<link>
http://www.webtekno.com/google/google-ve-razer-dan-oyun-konsolu.html
</link>

my code for get link from rss is:

HtmlNodeCollection nodeList = doc.DocumentNode.SelectNodes("//item");
foreach (HtmlNode node in nodeList)
{
    string newsUri = node.ChildNodes["link"].InnerText;
}

I think gets empty char cause link node includes new line and after link. How can I get link in the node?


Solution

  • Put that line before loading HtmlDocument

    HtmlNode.ElementsFlags["link"] = HtmlElementFlag.Closed;
    

    That is all.

    By default, its value is HtmlElementFlag.Empty and treated like meta and img tags...