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

Trying to get the value of an element inside the xml of an Xelement

I have an Xelement being passed into a function: ByVal request As XElement inside the Xelement object is an element: 1234567 I should be able to get this value by: request.Element("ID").value ...but it does not return anything. I…
Popo
  • 2,402
  • 5
  • 33
  • 55
0
votes
1 answer

How do I get values of attributes using XElement/LINQ?

I'm trying to get the values of every id attribute on every node. Getting all the attributes with .Descendants("foo").Attributes("id") is simple enough, but is there a way to get an IEnumerable (Of String) containing the values? I'd really prefer…
Thalecress
  • 3,231
  • 9
  • 35
  • 47
0
votes
1 answer

Changing the Value of an XElement

I am converting codes in an XDocument from one format to another. My code looks like this: if (translate.Count > 0) { foreach (XElement element in xml.Descendants()) { if…
Tim
  • 2,731
  • 9
  • 35
  • 72
0
votes
4 answers

Can't Retrieve Values of XML Elements using XElement

I am trying to read from an XML file that is supplied through a file browser but the values are alwas null even though I can see the xml file come through to elements. public void UploadXml(Stream fileStream) { //Load xml …
Jeff Finn
  • 1,975
  • 6
  • 23
  • 52
0
votes
1 answer

C# - XElement from XSD or XML

I have to dialogue with a webservice whose response accepts a XElement object that represents a XML file. I have generated a XSD file from the XML and, via xsd.exe, I have generated a .cs class. What I want to know is: how I can convert the object…
lugeno
  • 1,055
  • 3
  • 10
  • 18
0
votes
1 answer

XElement.Descendants("Node") not behaving as expected, returns multiple levels of Descendants

I have an issue. I have hierarchical XML data such as:
mfr
  • 149
  • 3
  • 11
0
votes
2 answers

Can not cast from base XElement class

I have such class: Public Class MyXElement Inherits XElement Public Sub New(other As XElement) MyBase.New(other) End Sub Public Sub New(name As XName) MyBase.New(name) End Sub Public Sub New(other As…
Dima
  • 1,717
  • 15
  • 34
0
votes
1 answer

Linq Query syntax System.Xml.Linq.XElement

I am querying an Xelement and attempting to get string values into another object Here is the Xml P Nursing ULE
Sonny123
  • 107
  • 1
  • 3
  • 12
0
votes
1 answer

Controling XElement Attribute Namespace Names

I'm in the process of building an export engine that will take our company's data and export it as XML based on the pattern provided in our database. One of the exports I need to implement must have the xsi:nil="true" attribute added to the element…
KevinK
  • 1
  • 1
0
votes
2 answers

searching for an unnamed nested XElement by a specific XAttribute

Here is what my XML looks like (Yes, I know the XML is ugly). I'm trying to search and remove any nodes from this XDocument that have the isConstField attribute set to "Y" without iterating through each individual XElement.
0
votes
1 answer

How I can fill my ASP.NET TreeView out of Code?

hi guys i have a problem with the treeview control in asp.net. I want to fill that with a xml file but the treeview in asp.net is diffrent to the window form treeview control :/ The name of my treeview is treeview...i don't have the xml in a folder…
Tarasov
  • 3,625
  • 19
  • 68
  • 128
0
votes
1 answer

Removing $#x0 from string

I have a string that I'm trying to parse to XML like this: XElement.Parse(XMLdata) But the problem I'm having is that XMLdata contains this text: $#x0 resulting in the following exception : '.', hexadecimal value 0x00, is an invalid character.…
0
votes
1 answer

How to pass a variable to element in XDocument using vb.net

Here is my code in VB.net. It displays AB, CD, EF. How do I make a subroutine so I can call like: Sub-name(field65, field547, field66)? Sub main()     Dim fileName As String = "C:\AAA\test5.xml"     Dim root As XElement =…
0
votes
2 answers

Getting XML Elements By ID in C#

XML Dog Han Cat Leia
user2395842
  • 3
  • 1
  • 2
0
votes
2 answers

How to add a node as a children to an existing node XElement?

Here is my code. XElement Response = new XElement("Response", new XElement("RequestId", requestID), new XElement("ResponseId", "E001"), new…
Dixit Gokhale
  • 601
  • 1
  • 12
  • 32