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
0 answers

How to re-serialize a modified object and insert back into an XDocument?

I have a nested set of objects represented in an XDocument as such: Red
IAbstract
  • 19,551
  • 15
  • 98
  • 146
1
vote
1 answer

Can I 'flatten' an XDocument with Linq?

I have a heavily nested XML document that I need to load into my db for additional processing. For various reasons beyond the scope of this discussion I need to 'flatten' that structure down, then load it into a DataTables and then I can SQLBulkCopy…
snappymcsnap
  • 2,050
  • 2
  • 29
  • 53
1
vote
2 answers

Edit Object with xml without creating new Instance

I have a class which needs to be a Singleton. It must also be able to load and save its field data in an xml file. The following method will return a new instance, which breaks my Singleton pattern, leaving potential bugs in my code. public…
Bob Coder
  • 391
  • 3
  • 13
1
vote
2 answers

Remove element from XML based on attribute value?

I was trying to remove a descendant element from an XElement (using .Remove()) and I seem to get a null object reference, and I'm not sure why. Having looked at the previous question with this title (see here), I found a way to remove it, but I…
Black Light
  • 2,358
  • 5
  • 27
  • 49
1
vote
1 answer

How can I use a class as a data model in querying XDocument?

I have an Xml document: Smith
IAbstract
  • 19,551
  • 15
  • 98
  • 146
1
vote
4 answers

Deploy XML file and load it

I have created an XML file in my solution path. My solution has multiple projects (one of them is a service), now some of these projects need to refer to the XML file When I try and use XDocument configXML = new XDocument.Load("Config.xml"); I…
Vivek
  • 1,451
  • 8
  • 42
  • 74
1
vote
2 answers

Writing LINQ to XML query for filtering a xml string

I have the following xml string: How do I write a Linq to xml query that filters by name = "Jane" and…
DotnetDude
  • 11,617
  • 35
  • 100
  • 158
1
vote
1 answer

Creating unique IDs for XElement at runtime LinqToXml

How do you create unique Id's for an XElement at runtime. Im using an object datasource for inerting XElements and I need to generate id's for the newly inserted XElement so I can return it id value
ONYX
  • 5,679
  • 15
  • 83
  • 146
1
vote
1 answer

Checking if value exists in name attribute

XDocument xmlDoc = XDocument.Load(xmlFile); bool exists = (from elem in xmlDoc.Descendants("root") where elem.Element("data").Attribute("name").Value == "ID1" …
Rod
  • 14,529
  • 31
  • 118
  • 230
1
vote
4 answers

Better way to do this LINQ to XML query?

So say I have this XML file:
Davy8
  • 30,868
  • 25
  • 115
  • 173
1
vote
1 answer

Can i specify a schema to build an XDocument while loading a xml file?

I am a xml newbie trying to create a XDocument type from a xml file. I can validate the xml against a schema. public class XmlHandler { public XDocument Read(string filename, string schemaname) { var schemas =…
mrt181
  • 5,080
  • 8
  • 66
  • 86
1
vote
2 answers

Does XDocument.Save(string filename) resave the whole file or just changes?

Basically if I do Xdoc.Load(filename), do some changes then do Xdoc.Save(filename) does it only save things that changed such as inserted or removed elements, etc, or does it resave everything? Depending on the answer I'm thinking of determining…
Davy8
  • 30,868
  • 25
  • 115
  • 173
1
vote
2 answers

How to GroupJoin from flat XDocument?

I have an XDocument with a fragment that resembles:
IAbstract
  • 19,551
  • 15
  • 98
  • 146
1
vote
3 answers

Read Complex XML

I have difficulties to read from that xml! I think XMLDocument would help but i don't know how to get value from each element in childNode! Especially, the childnode which has any childNode Inside like IdList. XML format : …
Oudam San
  • 77
  • 1
  • 10
1
vote
1 answer

How to set multiple property values with same name and counter value using reflection?

I have a class with a separate field for Email. Then I have fields as Email1, Email2, ..., Email9 I receive values in the form of xml like this
wasimbhalli
  • 5,122
  • 8
  • 45
  • 63