Questions tagged [xelement]

XElement is part of System.Xml.Linq in .NET Framework. This class represents an XML element, the fundamental XML construct.

An XElement has an XName, optionally one or more attributes, and can optionally contain content.

An XElement can contain the following types of content:

  • XElement
  • XComment
  • XProcessingInstruction
  • XText

Reference: XElement Class on MSDN

883 questions
0
votes
2 answers

How do delete XELEMENT in XDocument?

Peter 35 John 25 Micheal …
user707407
  • 25
  • 1
  • 8
0
votes
2 answers

Xml Linq, removing duplicate nodes in XElement C#

I use Xml.Linq for manage xml configuration files. I have XElement (Company.CalidadCodigo.ParserSQL.Reglas), and I need remove duplicate values in XElement (nodes Add-Key-Value, which Value is repeated). I use Union but not right. var reglasComunes…
Kiquenet
  • 14,494
  • 35
  • 148
  • 243
0
votes
1 answer

XElement.Decendents.First not finding xml field

I'm trying to read an XML file and find the value of a field. I am reading from file "MyMessage.txt": AAAA
Yoav
  • 143
  • 2
  • 9
0
votes
1 answer

Copying one Xelement in to another and then Manipulating the newer one is affecting the older also

I am making one Xelement from another. But when I am manipulating the new Xelement, it is changing the earlier one also. private bool myFunction(List jobList) { List tempJobList = new List(jobList); foreach…
mukul nagpal
  • 93
  • 1
  • 12
0
votes
2 answers

How to find out duplicate Elements in Xelement

I am trying to find out the duplicate Elements in XElement , and make a generic function to remove duplicates .Something like: public ListRemoveDuplicatesFromXml(List xele) { // pass the Xelement List in the Argument and get the…
mukul nagpal
  • 93
  • 1
  • 12
0
votes
1 answer

Linq xElement read - I need to read a parent value whilst reading nested dependencies

As title indicates I need to read a parent value whilst selecting dependency values. Whilst loading the Symbols into a collection I also need to add the 'CategoryDescription' value for each symbol. The code I am using to read the symbol data is…
Jim
  • 201
  • 2
  • 12
0
votes
2 answers

Looping through XElement items

I've the following…
Jeroen E
  • 57
  • 1
  • 10
0
votes
1 answer

C# XElement - add element before value of existing element

I have an XML string like this: Some text in here and i need to add another element just after the opening para tag, so that it reads My TitleSome text in here I've tried this but it doesn't give me what i…
Can'tCodeWon'tCode
  • 543
  • 1
  • 11
  • 36
0
votes
1 answer

Get the EndElement Node of an XElement

I am trying to get the End node of an XElement in a C# Console application. Say for example my XML Content is: Word 10 How can I fetch as a node? On iterating through…
Nathan
  • 1,303
  • 12
  • 26
0
votes
1 answer

Create XML fragment without xmlns namespace declaration

I am trying to create the following XML via code: This is a log message. But I do not manage to get rid of the…
Christoph Fink
  • 22,727
  • 9
  • 68
  • 113
0
votes
1 answer

How do I compose XDocument and keep the same namespace prefix throughout?

I'm having trouble composing an XDocument which uses two namespaces. When I add XElements created by a different method (which refer to the exact same XNamespace instances), I get a redeclaration of the xmlns with a different prefix. It's perfectly…
Bob Peterson
  • 636
  • 7
  • 16
0
votes
4 answers

Adding a new element to a XML file using LINQ XML (XDocument/XElement) using C#

I am trying to add (insert) a new element into the following XML; 1
user1224125
  • 21
  • 1
  • 5
0
votes
2 answers

How to recover all the XML elements in an XML tag?

This is a sample of my XML: .... ....
Millet Antoine
  • 405
  • 1
  • 6
  • 24
0
votes
2 answers

Adding XmlElement to a non-root node list using VB.NET

I'm trying to add a new element to an existing list of elements in an XML file. I'm using this code to initiate the Element: Dim newElem As XmlElement = doc.CreateElement("/Content/Catalog/Feature[7]/Option") But I get an error message saying…
kman
  • 3
  • 5
0
votes
2 answers

XML Document to IEnumerable and get values

Hey guys I'm trying to get some values from a deeper container in my xdocument but i always run in an Nullreference. This is my code so far: StreamReader xmlStream = new StreamReader(rsp.GetResponseStream()); string…
josef_skywalker
  • 1,047
  • 1
  • 9
  • 16