How can i parse html file in windows phone 7?

2019-09-15 15:10发布

Hi am using xml file given below,i want to parse html file .

<Description>
 <Fullcontent>
   <div id="container" class="cf">
    <link rel="stylesheet" href="http://dev2.mercuryminds.com/imageslider/css/demo.css" type="text/css" media="screen" />
        <ul class="slides">
            <li>Sonam Kapoor<img src="http://deys.jpeg"/></li>
            <li>Amithab<img src="http://deysAmithab.jpeg"/></li>
            <li>sridevi<img src="http://deyssridevi.jpeg"/></li>
            <li>anil-kapoor<img src="http://deysanil-kapoor.jpeg"/></li>
         </ul>
    </div>
  </Fullcontent>
</Description>

i want bind image with name

1条回答
劫难
2楼-- · 2019-09-15 16:13

You can install HtmlAgilityPack from NuGet (just search for agility). Parsing is also simple. Here is way for selecting image tags and taking source attributes:

HtmlDocument html = new HtmlDocument();
html.Load(path_to_file);
var urls = html.DocumentNode.SelectNodes("//ul[@class='slides']/li/img")
                            .Select(node => node.Attributes["src"].Value);

Btw looks like direct selection of attributes is not supported yet.

查看更多
登录 后发表回答