Questions tagged [linq-to-xml]

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

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

Related Links

5019 questions
1
vote
3 answers

Linq to XML - Deserialize to Object

I have been able to get Linq to XML to work, but I wanted to see if there was a more efficient way of applying the elements to an object rather then putting a foreach statement after I have traversed the xml? I know you can use lamba expressions,…
scarpacci
  • 8,957
  • 16
  • 79
  • 144
1
vote
2 answers

XDocument Parse String - Null Terminator Issue

So I'm getting data from a 3rd party in the form of an XML String. I want to then do the following messageString = Encoding.ASCII.GetString(messageBeingSent); messageString = messageString.Trim(); XDocument xmlDoc =…
ist_lion
  • 3,149
  • 9
  • 43
  • 73
1
vote
1 answer

Using XDocument with namespaces

I am reading an xmlfile via the XDocument class. The XML has namespaces in it, how do I use node.Element() with a namespace? I tried creating XNamespace but it didn't seem to work.. The XML is as follows:
Luke Wilkinson
  • 439
  • 8
  • 17
1
vote
1 answer

Update XML file from List

I have a XML file containing records like - 5726
inutan
  • 10,558
  • 27
  • 84
  • 126
1
vote
2 answers

Get filtered List from XML

I am using following code to get List from xml file - public static List GetListFromXml(string filePath) { using (TextReader reader = new StreamReader(filePath)) { XmlSerializer serializer = new…
inutan
  • 10,558
  • 27
  • 84
  • 126
1
vote
3 answers

How to filter XML elements using LINQ query for one attribute/field containing a particular substring?

Example: In the example above I would like to extract all the items with modes containing…
Ronald
  • 1,532
  • 4
  • 18
  • 34
1
vote
3 answers

Query not fetching all the records

I have a xml structure:
Navyseal
  • 891
  • 1
  • 13
  • 36
1
vote
1 answer

How to create objects based upon element or attribute

Need help in parsing the following XML. I am a newbie to Linq to XML. I want to parse all picture data in a single objects array, and I dont seem to find a way, Here is a sample xml,
user1069342
  • 31
  • 1
  • 3
1
vote
2 answers

how to loop in xml (XElement) and get values od Inside Elements

Consider this XML: I store this XML in XElemnt.How I can loop throw Person elements and get value ID,Name,LastName for each person?
Arian
  • 12,793
  • 66
  • 176
  • 300
1
vote
2 answers

Linq to XML select ancestors up to 2 levels

Given the XML below I need to recurively select the employee who's positions.position.manager_position matches a position parameter. How can this be achieved with linq to XML?
Burt
  • 7,680
  • 18
  • 71
  • 127
1
vote
1 answer

Linq to XML : Increase performance

I want to read a xml file using Linq. This xml file is composed of 1 header and N Sub-Elements like this :
Florian
  • 4,507
  • 10
  • 53
  • 73
1
vote
2 answers

How to extract a certain sub-elements depend on the condition using Linq to XML

I have the XML (not exactly this simple but just enough for my question). If I code like the following var xdoc = XDocument.Parse(@" Value 1 Value 2 Value 3
Mun
  • 13
  • 3
1
vote
1 answer

How to parse documents with or without xml namespaces?

I have some XML files to parse, some of them are like this: ... and other of them are without namespace:
Florian
  • 4,507
  • 10
  • 53
  • 73
1
vote
3 answers

Update XML file with Linq

I'm having trouble trying to update my xml file with a new value. I have a class Person, which only contains 2 strings, name and description. I populate this list and write it as an XML file. Then I populate a new list, which contains many of the…
Svein Erik
  • 531
  • 2
  • 11
  • 24
1
vote
3 answers

LINQ Refactoring

I refactored my foreach loop from this before: foreach (KeyValuePair[string, string] param in paramsList) { XmlElement mainNode = xmlDoc.CreateElement("parameter"); mainNode.SetAttribute("name", param.Key); mainNode.SetAttribute("value",…
Cante Ibanez
  • 291
  • 1
  • 3
  • 12