0

I am attempting to use C# XElement to parse html. In HTML, src attributes have urls and query strings containing ? and / Is it possible to make them parsable?

Hoy Cheung
  • 1,552
  • 3
  • 19
  • 36

1 Answers1

2

LINQ to XML is only designed to parse XML, not HTML. In fact, ? and / shouldn't cause a problem to LINQ to XML - although & in unexpected places will, along with unclosed or unbalanced tags.

You should use something like HTML Tidy or HTML Agility Pack to parse HTML, unless you know that the HTML you want to parse is actually valid XML.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194