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
1 answer

XElement null when attributes exist

Given the following xml: And given the following code: string file = "myfile.xml"; //Contains the xml from above XDocument document =…
Mike Cheel
  • 12,626
  • 10
  • 72
  • 101
0
votes
1 answer

Creating XML Hierarchy with recursion

I am trying to create a hierarchical tree structure like below in LINQtoXML. The number of child level is dynamic. It can be any number. public static XElement BuildTree(int…
Happy
  • 1,767
  • 6
  • 22
  • 26
0
votes
2 answers

XElement vs Dictionary

I need advice. I have application that imports 10,000 rows containing name & address from a text file into XElements that are subsequently added to a synchronized queue. When the import is complete the app spawns worker threads that process the…
user135498
  • 6,013
  • 8
  • 29
  • 29
0
votes
1 answer

Xelement tags issue

enter code herehey guys im having trouble with xelement when im trying to open the test page an unhandled exception appears and that because the tag doesn't match the closing in another line i tried to add the closings tag but the error happens…
m131313
  • 27
  • 1
  • 5
0
votes
1 answer

Insert XML file into existing XML file using LINQ to XML

Using some example code I found here on SO, I've put together a bit of code to open up an existing XML database, open up another XML file that's to be inserted into the first XML, get the descendants of the root node in that file, and append them to…
delliottg
  • 3,950
  • 3
  • 38
  • 52
0
votes
1 answer

Insert 'xml:base' into XElement root

How can one insert the 'XML Base' attribute/namespace (http://en.wikipedia.org/wiki/XML_Base) into the root of an XElement or XDocument? ... And, do that without messing up the whole XElement (e.g. by it trying…
Nicholas Petersen
  • 9,104
  • 7
  • 59
  • 69
0
votes
1 answer

How to create an XML of this structure

I'd like to create an xml structure like below: asd asd asd asd
Mikk
  • 455
  • 1
  • 13
  • 19
0
votes
3 answers

Getting null elements using xelement with c# .net

Let us consider the following xml document: Hines 206-555-0144 425-555-0145 from which I retrieve a value as var value = parent.Element("name").Value; The code above…
GowthamanSS
  • 1,434
  • 4
  • 33
  • 58
0
votes
1 answer

Parsing vcxproj with XElement - unable to retrieve inner Import

I am trying to parse a vcxproj file, using - any method I can (I have tried XPathDocument, XElement, XDocument... nothing works) The typical project configuration:
Thalia
  • 13,637
  • 22
  • 96
  • 190
0
votes
1 answer

Change/rename namespace prefix

I have an XELEMENT that contains these elements B< /ns8:title> Bob< /ns9:firstname>
Stan92
  • 453
  • 1
  • 8
  • 21
0
votes
1 answer

How to keep bindings when serializing a WPF usercontrol into an XElement

I'm trying to serialize a custom WPF user control that features a grid with a textblock that is bound to a dependency property named "Frequency". The snippet that defines the textblock is as follows (the definition of the user control is quite…
Nacho1984
  • 111
  • 6
  • 17
0
votes
2 answers

How can I load list of child elements from XML?

I need to list lineitems inside every inquiry. Below I only get inquiry' values but not list of it's lineitems. XElement myElement = XElement.Load("Inquiries.xml"); var query = from s in myElement.Elements("Inquiry") …
Dennis Zaitsev
  • 795
  • 2
  • 6
  • 8
0
votes
5 answers

While looping through a set of `XElements` using IEnumerable.Where() generates unexpected output

I have a problem with looping through a set of XElements. The behavior is not what I expected. A short re-written version of my code, so you can easily get my problem (console app in C#) IEnumerable q = from c in xml.Descendants(aw + "wd")…
0
votes
2 answers

Can I escape XML characters like brackets that are contained within XML literal syntax of VB.NET?

A while back, I asked this question: Does VB.NET have a multi-line string declaration syntax equivalent to c#? Here I was introduced to XML literals in VB.NET. Using this syntax, I was able to simulate the multi-line string syntax available in c#…
oscilatingcretin
  • 10,457
  • 39
  • 119
  • 206
0
votes
1 answer

Select unique XElements (by attribute) using LinqToXml

I have a XML where I have several tags. Some of them have attribute "ident" with value "pr", some not. blabla blabla
Juri Bogdanov
  • 295
  • 1
  • 11
  • 19