tagged [linq-to-xml]
Convert single XElement to object
Convert single XElement to object I have a single `XElement` looking like this: Then I have a class looking like this: ``` public class ProductAttribute { public string Flag { get; set; } public s...
- Modified
- 8 Apr at 07:23
How do you create an indented XML string from an XDocument in c#?
How do you create an indented XML string from an XDocument in c#? I have an XDocument object and the ToString() method returns XML without any indentation. How do I create a string from this containin...
- Modified
- 3 Mar at 22:24
Jaxb equivalent in C#
Jaxb equivalent in C# Using JAXB in Java it is easy to generate from a xml schema file a set of Java classes that xml conforming to that schema can be deserialized to. Is there some C# equivalent of J...
- Modified
- 19 Apr at 13:35
Converting XDocument to XmlDocument and vice versa
Converting XDocument to XmlDocument and vice versa It's a very simple problem that I have. I use XDocument to generate an XML file. I then want to return it as a XmlDocument class. And I have an XmlDo...
- Modified
- 2 Oct at 09:29
LINQ to XML: applying an XPath
LINQ to XML: applying an XPath Can someone tell me why this program doesn't enumerate any items? Does it have something to do with the RDF namespace? ``` using System; using System.Xml.Linq; using Sys...
- Modified
- 17 Oct at 20:6
Populate XDocument from String
Populate XDocument from String I'm working on a little something and I am trying to figure out whether I can load an XDocument from a string. `XDocument.Load()` seems to take the string passed to it a...
- Modified
- 12 Mar at 13:36
Forcing XDocument.ToString() to include the closing tag when there is no data
Forcing XDocument.ToString() to include the closing tag when there is no data I have a XDocument that looks like this: That when I call Outputs to this: ```
- Modified
- 22 Jun at 15:25
Find Elements by Attribute using XDocument
Find Elements by Attribute using XDocument This query seems to be valid, but I have 0 results. My XML is as follows: ```
- Modified
- 21 Apr at 20:27
XDocument.Descendants() versus DescendantNodes()
XDocument.Descendants() versus DescendantNodes() I've looked at [Nodes() vs DescendantNodes() usages?](https://stackoverflow.com/questions/9850733/nodes-vs-descendantnodes-usages) to see the differenc...
- Modified
- 23 May at 11:54
Parsing XML using XDocument
Parsing XML using XDocument Can I get some help parsing the "my_cool_id" from the following xml using XDocument? ``` 12345 12345
- Modified
- 17 Oct at 23:5
Query an XDocument for elements by name at any depth
Query an XDocument for elements by name at any depth I have an `XDocument` object. I want to query for elements with a particular name at any depth using LINQ. When I use `Descendants("element_name")`...
- Modified
- 17 Dec at 01:6
Convert XElement to string
Convert XElement to string I have a simple XElement object Where want to dump out the contents into a string. Exactly like how `Console.W
- Modified
- 1 Feb at 13:12
XDocument to XElement
XDocument to XElement How do you convert an XDocument to an XElement? I found the following by searching, but it's for converting between XDocument and XmlDocument, not XDocument and XElement. ``` pub...
- Modified
- 26 Jun at 01:7
How to get a JSON string from URL?
How to get a JSON string from URL? I'm switching my code form XML to JSON. But I can't find how to get a JSON string from a given URL. The URL is something like this: "https://api.facebook.com/method/...
- Modified
- 1 Apr at 16:28
How to convert XmlNode into XElement?
How to convert XmlNode into XElement? I have an old `XmlNode`-based code. but the simplest way to solve my current task is to use `XElement` and LINQ-to-XML. The only problem is that there is no direc...
- Modified
- 3 Jan at 23:19
The ':' character, hexadecimal value 0x3A, cannot be included in a name
The ':' character, hexadecimal value 0x3A, cannot be included in a name I have an xml file that contains its element like When I am trying to access it using the code: It's giving me this error: > Sys...
- Modified
- 17 Jan at 18:17
How do I deserialize XML into an object using a constructor that takes an XDocument?
How do I deserialize XML into an object using a constructor that takes an XDocument? I have a class: I would like to be able to use an XMLSeralizer to Deserialize an XDocument directly in the construc...
- Modified
- 26 Oct at 10:49
How create XElement with specific namespace?
How create XElement with specific namespace? I have problem with creating new element in LinqToXml. This is my code: I want to get th
- Modified
- 21 Aug at 07:24
Regex in Linq statement?
Regex in Linq statement? I'm writing a short C# to parse a given XML file. But 1 of the tag values can change, but always includes words "Fast Start up" (disregarding case and spaces, but needs to be ...
- Modified
- 4 Jun at 16:25
get xelement attribute value
get xelement attribute value I have an XElement that looks like this: How can I use XML to extract the value of the LoginName attribute? I tried the following, but the q2 "Enumeration yielded no resul...
- Modified
- 22 Jul at 14:24
C# XDocument Load with multiple roots
C# XDocument Load with multiple roots I have an XML file with no root. I cannot change this. I am trying to parse it, but `XDocument.Load` won't do it. I have tried to set `ConformanceLevel.Fragment`,...
- Modified
- 13 Aug at 08:39
How to convert XML to Dictionary
How to convert XML to Dictionary I've xml as following: I success to do that without Linq, any one can help me to convert the following code to Linq: ``` using (XmlReader reader = XmlReader.Create(_xm...
- Modified
- 19 Dec at 13:13
Unexpected exception from XDocument constructor
Unexpected exception from XDocument constructor This works fine: However if I change it to pass the "params array" explicitly as an array: ``` object[] content = new object[] { new XDeclaration("1.1"...
- Modified
- 16 Aug at 12:2
Remove empty XML tags
Remove empty XML tags I am looking for a good approach that can remove empty tags from XML efficiently. What do you recommend? Regex? XDocument? XmlTextReader? For example, ``` const string original =...
- Modified
- 12 Oct at 18:18
How to specify an xmlns for XDocument?
How to specify an xmlns for XDocument? I tried: But I get: I also tried substituting (accor
- Modified
- 12 Feb at 20:14