Html parse for Windows Phone 8.1

Topics: Developer Forum
Sep 26, 2014 at 2:30 PM
Edited Sep 26, 2014 at 2:56 PM
I'm trying to create a wp 8.1 application that takes a web page content. My problem is that xpath doesn't seem to work for WP8.1, so i'm trying to use LinQ, but i don't understand it very well.
The page is this:
<body>
    <table cellspacing="0" cellpadding="0" border="0" style="border-style:none; padding:0; margin:0;" id="ctl00_ContentPlaceHolder1_ListView1_groupPlaceholderContainer">               
         <tbody>
             <tr style="border-style:none;padding:0; margin:0; background-image:none; vertical-align:top;" id="ctl00_ContentPlaceHolder1_ListView1_ctrl0_itemPlaceholderContainer">         
                 <td style="border-style:none;padding:0; margin:0; width:22%;" id="ctl00_ContentPlaceHolder1_ListView1_ctrl0_ctl01_Td3">
                    <div class="photo">
                        <a target="_self" title="PH1" href="fumetto.aspx?Fumetto=279277">PH1_1</a>
                    </div>
                </td>
            </tr>
            <tr style="border-style:none;padding:0; margin:0; background-image:none; vertical-align:top;" id="ctl00_ContentPlaceHolder1_ListView1_ctrl0_itemPlaceholderContainer">          
                 <td style="border-style:none;padding:0; margin:0; width:22%;" id="ctl00_ContentPlaceHolder1_ListView1_ctrl0_ctl01_Td3">
                    <div class="photo">
                        <a target="_self" title="PH2" href="fumetto.aspx?Fumetto=279277">PH2_1</a>
                    </div>
                </td>
            </tr>
            <tr style="border-style:none;padding:0; margin:0; background-image:none; vertical-align:top;" id="ctl00_ContentPlaceHolder1_ListView1_ctrl0_itemPlaceholderContainer">          
                 <td style="border-style:none;padding:0; margin:0; width:22%;" id="ctl00_ContentPlaceHolder1_ListView1_ctrl0_ctl01_Td3">
                    <div class="photo">
                        <a target="_self" title="PH3" href="fumetto.aspx?Fumetto=279277">PH3_1</a>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
</body>         
I want to save the attributes "PH1", "PH2", "PH3" and the values "PH1_1", "PH2_1", "PH3_1". Can you help me? My code is this:
string filePath = "...";
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.OptionFixNestedTags = true;
htmlDoc.LoadHtml(filePath);
if (htmlDoc.ParseErrors != null && htmlDoc.ParseErrors.Count() > 0)
{
    // Handle any parse errors as required
}
else
{
    if (htmlDoc.DocumentNode != null)
    {
        //I'm trying to get the first node for now
        HtmlAgilityPack.HtmlNode aNode = htmlDoc.DocumentNode.DescendantsAndSelf("a").FirstOrDefault();
        if (aNode != null)
        {
            string first = aNode.GetAttributeValue("title", "null");
            string value = aNode.ToString();
        }
    }
}
The problem is that first is "null" and not "HP1" and value is the link of the page instead of "HP1_1". And if i try to use Descendants() instead of DescendantsAndSelf i get a null node.