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

Select subelements from XElement into new XElement

I'm trying to select some childelements from my object XElement and put them in a new XElement. var objNodes = doc.Descendants("object") .Where(node => node.Attribute("table").Value == idbsObject.Key) .Select(item => new…
Sybren
  • 1,071
  • 3
  • 17
  • 51
0
votes
1 answer

XElement.Value not reading multi-line data

I current have the following XML fragment that I'm parsing to read its values and display them on a web page: The Needles Granite Dells, Prescott
Dillie-O
  • 29,277
  • 14
  • 101
  • 140
0
votes
1 answer

Adding child nodes to an XElement

I am trying to append objects into an XML file. The problem I currently have is it appends everything at the first level itself. I am trying to have the list as the parent element and list items as the child elements. What I've tried: I came across…
Naaz
  • 91
  • 1
  • 10
0
votes
2 answers

XElement Sequence contains no elements why?

Here is the XML I am querying: OK street_address 264 Mugga Ln, Canberra ACT, Australia
Aaron
  • 1,802
  • 3
  • 23
  • 50
0
votes
5 answers

c# LINQ get Attribute value from XElement

I have the below XML in a data definitions file:
Our Man in Bananas
  • 5,809
  • 21
  • 91
  • 148
0
votes
1 answer

xElement query equivalent for sql like

I am extracting data from a xml document into a structure using an xElement query. I would like to limit the data being stored to only when certain fields contain part of a particular string. This code works, but the string has to be an exact…
0
votes
0 answers

Adding new xElement after ALL found Descendants

I have an xDocument with multiple various xElements. I can successfully find a specific xElement by searching via it's xAttributes & then Add a new xElement after it using the code below: xDocument.Descendants("td").LastOrDefault(e =>…
1cm69
  • 177
  • 2
  • 16
0
votes
1 answer

How to get a tablerow out of an xelement?

I have this xelement: as you see there are several attributes in the element adress and it inherits the…
steve
  • 123
  • 1
  • 14
0
votes
2 answers

Dynamically creating XElements inside XDocument using a loop

I need to be able to dynamically create 'n' number of XElements inside an XDocument using a loop and depending on the number of files found within a directory. My WIP bare bones project code is possibly slightly long to paste here so I have added it…
1cm69
  • 177
  • 2
  • 16
0
votes
1 answer

query for select value in xelement

I have a XMl like this : test1 yahoo.com
Sara
  • 209
  • 1
  • 3
  • 10
0
votes
2 answers

Extract a Byte[] from an XElement with Linq to Xml

I am saving some small images to Xml as a Byte[] via the following XElement construct.. XElement xe = new XElement("Images", from c in qry select new XElement("Image", new XAttribute("Date", c.Date), new…
Tim Jarvis
  • 18,465
  • 9
  • 55
  • 92
0
votes
2 answers

Bug: List remains in memory if file deleted, and saves data twice if file is deleted

got an odd bug in my code and I can't see why it's behaving the way it is. I'm not the most experienced code warrior so hoping someone with a bit more experience can see why. I'm saving a list of objects to an XML file. I pass the list of the…
0
votes
2 answers

How to use foreach loop inside a Xelement in c#

XElement doc = null; doc = new XElement("root"); foreach (var content in emailContents) { doc.Add(new XElement("Email", new XElement("FromAddress", content.FromAddress), new…
rohit singh
  • 550
  • 1
  • 11
  • 32
0
votes
2 answers

how to update xattribute values in an xelement where attribute is in list?

Hello I have an Xelement which looks like this: dim elementfromwebservice as xelement=
SteveM
  • 13
  • 4
0
votes
1 answer

c# AXL XElement Data to datagridview

I'm busy with a application that extract data from Cisco CUCM to Datagridview with AXL/SOAP. I get only the last record in the datagridview if I put the info to a combobox I get the compleet list. The info what I extract with AXL is: …