Top "Linq-to-xml" questions

LINQ-to-XML provides a SQL-like query experience for navigating, parsing, and aggregating data stored in XML documents.

Find Elements by Attribute using XDocument

This query seems to be valid, but I have 0 results. IEnumerable<XElement> users = (from el in XMLDoc.Elements("…

c# xml linq linq-to-xml
How to use XPath with XElement or LINQ?

Consider the following XML: <response> <status_code>200</status_code> <status_txt>OK&…

.net xml xpath linq-to-xml xelement
Search XDocument using LINQ without knowing the namespace

Is there a way to search an XDocument without knowing the namespace? I have a process that logs all SOAP …

c# linq-to-xml
' ', hexadecimal value 0x1F, is an invalid character. Line 1, position 1

I am trying to read a xml file from the web and parse it out using XDocument. It normally works …

encoding linq-to-xml windows-phone
XElement => Add children nodes at run time

So let's assume this is what i want to achieve: <root> <name>AAAA</name> &…

c# xml linq-to-xml xelement
Children of XElement

How do I get just the children of an XElement? I am currently using the XElement.Descendants() function, which returns …

c# xml linq-to-xml xelement
XDocument containing namespaces

I have the following XML which I am trying to query with XDocument: <E2ETraceEvent xmlns="http://schemas.microsoft.…

c# xml linq linq-to-xml xml-namespaces
XDocument.ToString() drops XML Encoding Tag

Is there any way to get the xml encoding in the toString() Function? Example: xml.Save("myfile.xml"); leads to &…

c# linq-to-xml
linq question: querying nested collections

I have a Question class that has public List property that can contain several Answers. I have a question repository …

c# .net linq collections linq-to-xml
How to remove xmlns attribute of a node other than root in an XDocument?

Situation I'm using XDocument to try and remove an xmlns="" attribute on the first inner node: <Root xmlns="http://…

c# .net xml linq-to-xml xml-namespaces