无法将Xpath值分配给字符串

时间:2014-09-22 13:46:43

标签: string

我只是尝试将从html页面获取的值分配给字符串,但是在App.xaml.cs中的Application_UnhandledException方法失败了

虽然我是WP8的新手,但请帮助我理解原因并解决它。谢谢大家。

我的代码:

HtmlAgilityPack.HtmlNode imageNode = doc.DocumentNode.SelectSingleNode("//div[@class='fck_detail width_common']/table/img[@src]");
string imgUrl = imageNode.Attributes["src"].Value;

App.xaml.cs中的Application_UnhandledException失败

 private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
    {
        if (Debugger.IsAttached)
        {
            // An unhandled exception has occurred; break into the debugger
            Debugger.Break();
        }
    }

1 个答案:

答案 0 :(得分:0)

几天后,我发现了这一点。只需要在通过下面的代码

加载Html文档之前将xml的行为修复1行
HtmlAgilityPack.HtmlNode.ElementsFlags.Remove("img");