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 nodes with specific child node when xml can be different

I have code that's working, but I'd like to see if there's a nicer and better solution than what I have (I'm sure there is!). I have a webservice that needs to return all nodes that has a child node called "updatedDate" with a date more recent than…
annelie
  • 2,569
  • 6
  • 25
  • 39
0
votes
2 answers

Given XElement - Find node text by node name

I have loaded an XML document into an XElement It looks a little like this:
baron
  • 11,011
  • 20
  • 54
  • 88
-1
votes
1 answer

When using C# XmlSerializer and SetElementValue on an XElement when you set it the value to null or empty string it's removed

If you open an XML Document with XDocument.Load(path) and then look through Descendants when you find the one you are looking for and use SetElementValue if you set the value to an empty string ("") or null it ends up removing the tag so when you…
Chris Ward
  • 771
  • 1
  • 9
  • 23
-1
votes
1 answer

best approach to read a difficult XML into a list with C#

I need to read the values out of following XML in C#. The XML here is just a small portion of the whole XML. It's a savegame. Deserialization probably won't work because of the complex nature.
mJrA
  • 11
  • 3
-1
votes
1 answer

How can I maintain the treestructure of my xml-file in the code and access the "subtags"?

Hey have a little problem, I'm having a xml-file structured like this:
-1
votes
2 answers

Why this XPathSelectElements() returns false?

Consider the snippet below: var xpath = "//i[@a='1']"; var item = new XElement("i", new XAttribute("a", "1"), new XAttribute("b", "2"), new XAttribute("c", "3")); Console.WriteLine(item); //
Rubens Farias
  • 57,174
  • 8
  • 131
  • 162
-1
votes
1 answer

maximum DateTime in XML

I am trying to find the maximum DateTime value in my XML. Here is a sample of the XML:
Saber Motamedi
  • 362
  • 3
  • 27
-1
votes
1 answer

Adding Elements to an XDocument c#

Hi there i am having troubles finding a solution merging 2 XML codes together. Could someone please tell me how i can merge my initial Xdocument with INSERT below: Any help is appreciated! Thank you INITIAL XDOC: XDocument doc = new…
-1
votes
2 answers

Convert many text files in xml files, keeping the same file name C#

UPDATED - I'm trying to convert a lot of text files (up to 3K files) to XML files, using C#. There are two steps that I would like to follow: 1) Get some data using specific delimiter ":". 2) Use the same name of *.txt file to create *.xml file in…
Everton Wcks
  • 99
  • 1
  • 6
-1
votes
2 answers

How to return variable which in declared with in loop c#

private XElement AuthorSeparate(List authorName) { string surName = string.Empty; string initalName = string.Empty; string givenName = string.Empty; int j = 1; for (int i = 0; i <…
Malathi
  • 43
  • 7
-1
votes
1 answer

Writing XML file to Users Browser and download

I am writing XML data to the user browser for download. Below is the code protected void WriteXmlToPageDownload(XElement XmlCustomerData) { try { if (XmlCustomerData != null) { …
Troy
  • 11
  • 3
-1
votes
1 answer

How to read all attributes conditionally?

I want to read all attributes as IEnumerable using where clause. So what I want is - return Employee as List where List = PayList Below is my XML.
-1
votes
1 answer

Can I get the length of the values in a tag

I have an XML file that starts with:
boaz
  • 920
  • 1
  • 13
  • 32
-1
votes
2 answers

Linq Xelement and Class

So, let me explain my trouble. I get a project which was develop by another guy, and he leaved the firm. Now i have to update the program but something going wrong when i import the solution. Let see the code: ListeDeTypeDePoste = (from e in…
-1
votes
2 answers

xml parsing - code refactoring issue

I have the following xml: P1 P2 false 100 50
App
  • 346
  • 3
  • 9