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

Update a specific XML Element without caring what value is there

Although there are a lot of examples on how to do this, I seem to be stuck and I cannot find anything out there to help me. I want to update the value of the index without testing it's previous value. I know this must be easy but I'm stumped. I…
Rick
  • 65
  • 1
  • 9
0
votes
2 answers

Get XElement Value

I have an XElement object which I would like to get its value as string. However, the ToString() method returns the xml tree with /r/n and spaces which I woild like to ignore. Is there an attribute of XElement which retrieves the XML tree as…
user3165438
  • 2,631
  • 7
  • 34
  • 54
0
votes
1 answer

Iterating through Xdoc decendends adding Xelements

I'm trying to make a project manager program, to help organize my project files. It uses Xdocs to store the project information. My problem is that now I wish to include a more structured view of the files associated with the project. That should…
user3061078
0
votes
1 answer

How to add mixed Text and XElements on XElement value

I am trying to add as value to an XElement mixed text and inline elements. For example when setting the string "this is a mixed text and inline element." the XElement.Nodes to be able to return the text node as XmlNodeType.Text & the…
Nick T
  • 311
  • 2
  • 5
0
votes
1 answer

skipping first line of csv when converting to XML in c#

I am using XElement to create XML from a CSV in c#. I need to skip the first line and then process accordingly. I would like to skip the header of the csv so I am not publishing those values to the XML (THE FIELD[0] is dummy data for testing…
Brock Davis
  • 159
  • 1
  • 5
  • 14
0
votes
1 answer

C# readout value-dependent content from XML-file via XElement

I have to readout all the username-dependent settings (parameter: 'name' and 'visible') in C# and store it to an List in the order 'name' then 'visible' and so on. So the list-content should be (at client-username:…
phonophunk
  • 67
  • 8
0
votes
0 answers

How can I display IEnumerable type in GridView?

I need to retrieve data from an XML file then display this result set in GridView by using LINQ. I have read the XML file from disk and fetched the elements I want, but I need to display these results in table. What should I do? C# code: …
0
votes
1 answer

Extracting a list of XElements from an XDocument with where clause

I have an XDocument object from which I am trying to extract all the List which specify a specific criteria. Following is my XML 001
user2179891
  • 33
  • 1
  • 4
0
votes
1 answer

WP8 create xml file c#

I am trying to create xml file like below ABCD Nokia Lumia 525 Contact
Ajay
  • 6,418
  • 18
  • 79
  • 130
0
votes
2 answers

How to convert XElement object into a dataset or datatable?

I'm accessing a SharePoint(2007) list through a service reference of lists.asmx created in my console application. Console application is created in VS2012 and .Net 4.5 framework. ListsSoapClient proxy1 = new…
DotNetIsFun
  • 1
  • 1
  • 5
0
votes
0 answers

How to parse single xml node in windows phone

1234 how do I pasrse this single xml node and it comes from web service response, I am using: void webservice_completedeventArgs() { XDocument doc = XDocument.Parse(e.Result); } this code runs very well in Emulator but in device when…
Viraj Shah
  • 308
  • 1
  • 12
0
votes
3 answers

Check whether a particular node exist in xml data

I have an xml data given below. I need to check whether an employee of empName="John" exists in Production department. If exists update the salary otherwise add an employee to the department.
Sudha
  • 2,078
  • 6
  • 28
  • 53
0
votes
1 answer

Trying to find element in XML response

This is my code to retrieve an element from XML: private async Task PostAsXmlRequestAsync(XElement parameter, CancellationToken responseToken) { using (var client = new HttpClient()) { client.BaseAddress = new…
user3444535
  • 233
  • 1
  • 2
  • 12
0
votes
2 answers

How to do edit text content keeping it in a CDATA block?

I want to edit the contents of a cdata block in this an document. Here's a simplified example: 22/7]]> I tried var element = XElement.Parse(" 22/7]]>"); element.Value = element.Value.Replace(">…
Colonel Panic
  • 132,665
  • 89
  • 401
  • 465
0
votes
2 answers

Strange result when adding HTML string to XElement

SOLVED: The problem was that I had my parenthesis in the wrong place. I had: if (!String.IsNullOrEmpty(Text)) xElement.Add(new XElement("rtf"), Text); Instead of: if (!String.IsNullOrEmpty(Text)) xElement.Add(new XElement("rtf", Text)); I have a…
Kevin
  • 4,798
  • 19
  • 73
  • 120