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

XElement iteration failing?

I'm trying to iterate over XElements so that they can be updated where a child element meets a condition. I've looked at answers from other posts and, as far as I can see, the method I'm using should work (but doesn't). The first line of code…
steverofe
  • 51
  • 1
1
vote
1 answer

Checking an XElement for Existence of One of Several Possible XElements

Is there a way to determine if an XElement contains one of any specified elements? For example, I have XElements that I'll want to check: Dim xe1 = Dim xe2 = Dim xe3 = Dim xe4…
Todd Main
  • 28,951
  • 11
  • 82
  • 146
1
vote
2 answers

how to add a child node inside a nother child node

How do I add another concept node (Concept Key="1234"R) to the child Rssd node where rssd = 3284070 in C#, I'm using XElements to contruct all the XML. Do I need a linq statement?
chuckd
  • 13,460
  • 29
  • 152
  • 331
1
vote
2 answers

Add child elements to XML

Can somebody put me in right direction? What I want to do is get output from WebMethod: I get the values from a database; 1694.152344;1694.092285;1693.972168;1693.852051 2013-07-10 20:00:00;2013-07-10 19:00:00;2013-07-10 18:00:00;2013-07-10…
1
vote
1 answer

Add namespace with colon to xml file

I need to generate a xml file that looks like this: ValueA ValueB This is my code: const string ns =…
sventevit
  • 4,766
  • 10
  • 57
  • 89
1
vote
1 answer

How to convert XText to XElement

Say i have a XText declaration something like XText FirstName = new XText("Rufus"); How to convert it to XElement?
user2533025
1
vote
1 answer

XElement.ReplaceWith throwing System.AccessViolationException

I'm working on an WindowsPhone 8 app that stores and reads it's data from its IsolatedStorage. I'm using Visual Basic.NET and LINQ to XML. There's no problem with loading/saving the data, but I've got a serious issue with replacing an XElement with…
1
vote
3 answers

Is LINQ to XML's XElement ordered?

When I use LINQ to XML, is the order of the elements and attributes written out to text guaranteed to be the same order as how I added the XElement and XAttribute objects? Similarly, when I read in an XML document, is it traversed in the same order…
sleepp
1
vote
2 answers

How can I write XML output?

How can I see the XML output of following C# code? I can see that it uses XElement, but where I can locate the XML file or the output? private void Form1_Load(object sender, EventArgs e) { XElement doc = new XElement("searchresults"); // root…
SmartestVEGA
  • 8,415
  • 26
  • 86
  • 139
1
vote
2 answers

How to find XElement specific Children (in c# with LINQ)?

I've got an XML file like this :
user2382465
  • 23
  • 1
  • 4
1
vote
1 answer

How to get XElement.ToString() to omit the space before the self-closing slash?

By default, a self-closing tag is ToString()ed by XElement as follows: However, I would like it without the extra space, i.e. Is this possible with the XElement API?
Timwi
  • 65,159
  • 33
  • 165
  • 230
1
vote
2 answers

Sorting an XDocument based on name of XElement

I have an XML file like this:
Deepanjan Nag
  • 901
  • 3
  • 14
  • 26
1
vote
1 answer

XElement.Elements(XName) method unable to read xml nodes having attributes

I am trying to filter the xmldata using Linq to Xml,the problem is i am not able to get the elements using XElement.Elements(Xname) method but when working with XElement.Desendents(Xname) method it works fine but displays all the element which i…
Abhinav
  • 75
  • 1
  • 1
  • 11
1
vote
0 answers

XElement descendant not working \ XElement.Parse()

Here is the (simplified) XML I am currently working with:
Atrus
  • 99
  • 1
  • 1
  • 9