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

Exception when using XName and namespace

I have an XML file that I must read. I am using XmlReader combined with XElement. The problem is when I try to use this syntax: var test = field.Element(nameSpace + "value").Value; I get this exception: The character ':', hexadecimal value 0x3A,…
Daniele Sartori
  • 1,674
  • 22
  • 38
0
votes
1 answer

WPF Filter Datagrid

I have a datagrid that I want to filter based on a value selected from a combobox. The source of the datagrid is an XML file. Below is the code I am using. When I trace the code the view filter is returning true and false correctly for each row but…
novacara
  • 2,207
  • 4
  • 24
  • 34
0
votes
1 answer

Read the file count in a public AWS S3 bucket

I am able to retrieve the XML which contains the info about the files using the below piece of code: XElement responseXML = XElement.Load(AWS_S3_URL); ICollection fileElements = responseXML.Elements("Contents") as…
Vipin Verma
  • 5,330
  • 11
  • 50
  • 92
0
votes
1 answer

Conditionally Include XElement in LINQ Select Operation?

I have working code in which I create a new var of type EnumerableRowCollection < XElement >. I have a new requirement where one of the XElements representing an Address must be conditionally included based on a Document Type value. public class…
CodenameCain
  • 573
  • 1
  • 9
  • 22
0
votes
1 answer

Remove duplicates of XNodes

I'd like to merge XML files, but without duplicates of the same XNodes. At this point if I have two identical XML files - with the same Privilege nodes - then my merge will have duplicates like this: Input 1:
fota666
  • 141
  • 1
  • 9
0
votes
1 answer

Problem saving a new item to custom SharePoint 2007 list using Silverlight 4 UI control

I am hoping someone might be able to help me. I'm working on a Contact Manager built using a custom SharePoint 2007 list with a Silverlight 4 UI embedded in a content editor web part. I am currently able to retrieve the data from the list and…
Charles Green
  • 413
  • 3
  • 15
0
votes
0 answers

XElement with StreamReader/Writer slow over time

I have a 4.6 million line XML file. Each line represents an XML string. I wrote a simple app to shred the XML into a pipe delimited file. Over time my app gets slow, writing out a fraction of the number of lines per minute. Can anyone review my code…
Aaron Hurst
  • 109
  • 2
  • 3
  • 13
0
votes
1 answer

Saving XElement asynchronously

I am currently writing an XML Tree (XElement) to a file synchronously using XmlWriter, specifically via XElement.WriteTo(XmlWriter) on the root element. I'm trying to make that asynchronous (with an await). XmlWriter can be made asynchronous…
Jimmy
  • 5,131
  • 9
  • 55
  • 81
0
votes
1 answer

How to add Inner Xelements of an Xelement to other XElement at some specific position in asp.net

This is Xelement("elementExamQuestion ") I have created. XElement elementExamQuestion = new XElement("ExamQuestions", new XAttribute("id",…
0
votes
1 answer

How can i iterate through if statement with condition if (i < current Subject nodes inside xml file ) then display data for each

Here is my current code which outputs the modules in 1 single input textbox. XElement root = XElement.Load("Data.xml"); var subjects = from subject in root.Descendants() where…
Steven
  • 79
  • 2
  • 11
0
votes
2 answers

How can I store variable data into a label?

Here is some code I have already have which outputs the data : { SubjectName = maths, SubjectId = qq1, SubjectValue = 20 } { SubjectName = science, SubjectId = sla1s, SubjectValue = 25 } here is the code which does this: XElement root =…
Steven
  • 79
  • 2
  • 11
0
votes
1 answer

read remote xml from server using c#

Hello i am trying to get simple xml file from server and to read the data so i can convert it to list. I was try few lib and code with no success so far. I am getting the xml content in one line without any tags <> and the count is always 0 zero.…
Elidotnet
  • 291
  • 3
  • 18
0
votes
3 answers

how to convert xml to list of objects

Here is the code my goal is to iterate over all the nodes and not just one so in my case it gets the first Device Node and all his children at once so how can i get every single Device and PortA PortB nodes. then i will be able to set my class…
Jawad Halaby
  • 21
  • 3
  • 8
0
votes
2 answers

c# write from list of objects to XML file

i am facing a problem with writing to xml file using XDocument and XElement here is the wrong output file and how it should be. this is how the final xml file look like but it does not meet the requirements.
Jawad Halaby
  • 21
  • 3
  • 8
0
votes
1 answer

javascript in XElement

What is the correct way to put javascript in an XElement object in C#? Currently I have the following: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using…
1408786user
  • 1,868
  • 1
  • 21
  • 39