XML Parsing with HtmlAgilityPack

azure-worker-roles c# html-agility-pack web-services xml

Question

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?

1
2
7/5/2014 10:54:57 PM

Accepted Answer

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...

8
7/5/2014 11:26:42 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow