I have an XML string
No you don't. You have something that can be refered to as an "XML Fragment". Specifically because there is not a single root element it is not an XML document. (There is no such thing as "Invalid XML": it is either valid or it is not XML).
XML Parsers require an XML document. But XmlSeriailsie
is not just a parse: it includes an XML parser (of course) but also wants to generate an object graph from the content of the XML document making lots of assumptions about type availability and restrictions on the XML to match those types
The easiest approach with normal XML parsers would be to add a root element yourself. eg.:
var xdoc = XDocument.Parse("<myRoot>" + theString + "</myRoot>");
however for XML Deserialisation you will need to modify your available types to include a container that serialises with a myRoot
element and then contains the relevant information.
However given the sample XML I see no sign of that looking like an object graph. Why not work with the parsed XML and extract the content using the parser's API?