Workaround for "undeclared prefix" error in XElement.Load ()

I pull out the source of the website. Then I want to extract a specific part. I intend to do this using LINQ-to-XML.

However, I get errors while parsing the source:

XElement source = XElement.Load(reader);

It seems that the problem is with namespaces that I don't have. I get an error: 'addthis' is an undeclared prefix. Line 130, position 51.due to this line:

<div class="addthis_toolbox addthis_pill_combo" addthis:url="http://www.foo.com/foo">

And if I delete this one, another will happen.

Thing , I don't care what one fragment of this XML file is - I don't need to parse the whole file. I just want it in XElement to find it. Is there a way to crack a parsing error? And I need a general solution - I want to parse the file regardless of ANY undeclared prefix.

thank

+5
1

XML .

(, addthis:), , xmlns:addthis="some URI".

, HTML XML, HTML, , XML, ( , unescaped JS, ).
HTML Agility Pack.

+5

All Articles