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
1
vote
2 answers

Inserting Variable into Inline XML in VS2008

so i have some inline XML Dim x As XElement = _ what I want to do is get some variables that have been set into that xml Dim v as string = "Blah" Dim x As XElement = _ …
Russ Bradberry
  • 10,705
  • 17
  • 69
  • 85
1
vote
1 answer

How do I add a namespace to only ref elements in C#?

I have an XElement which contains the content that I want. However, I want to add a namespace prefix to only the ref elements. Is this possible in C#? For example, the original XML looks like this:
EagerNoob
  • 101
  • 2
  • 13
1
vote
1 answer

KML generated with XElement is corrupted when namespace is applied

I am working on a project to generate some KML data from our delivery database. I'm happy with building the KML structure using LINQ but it appears that when the namespace attribute is applied to the node I am then unable to output the data to a…
TeamWild
  • 2,460
  • 8
  • 43
  • 53
1
vote
1 answer

XElement.SetText encoding issue with single and double quotes

I have a very specific problem with the XElement class in regards to an applciation I am working on. Say I try setting the element value to "test & testing more < >" XElement tester = updatedElement.XPathSelectElement("Test"); …
james31rock
  • 2,615
  • 2
  • 20
  • 25
0
votes
2 answers

Reading from an attribute that might be missing in a xelement.add method in C#

I am trying to create a XElement that reads from another XElement built from a file. Below is a sample of the code. My question is how do I code around a source attribute that might not be there? docHeader and invoice are XElements. When running…
Styxtb1598
  • 23
  • 2
0
votes
3 answers

When using an XElement once, declare inline or create its own object?

When I am using an XElement once, should I declare it inline e.g. user.name = new XElement("Name", "John Doe"); or declare the XElement on its own line, e.g. XElement elem = new XElement("Name", "John Doe"); user.name = elem;
Meyer Denney
  • 796
  • 1
  • 11
  • 34
0
votes
2 answers

How to find out a child's parent?

I'm trying to use XElement to find out the parent node of a child. See the example below. This is my data: King Mike
user929153
  • 475
  • 2
  • 11
  • 25
0
votes
1 answer

XElement modification, how do I edit the attributes?

I have an xelement which is basic html, i want to quickly loop through all the elements that are paragraph tags and set the style attribute or append to it. I am doing what is below, but it is not changing the master xelement. How can i make this…
box86rowh
  • 3,415
  • 2
  • 26
  • 37
0
votes
1 answer

XML parsing using XElement and child contents

I have a function that returns the value from a specific tag in an XML document: XElement elem = XElement.Parse(xml_string); string ret = elem.Element(key).Value.ToString(); return ret; I'm trying to figure out…
joelc
  • 2,687
  • 5
  • 40
  • 60
0
votes
1 answer

DataSet.GetXmlSchema() do not returns nillable attribute

I'm serializing DataSet using GetXmlSchema() and GetXml() methods (code below), but in schema and xmlData there is no xsi:nil or nillable attributes for columns which are nullable. When deserializing how could I know that column is…
Anatolii Gabuza
  • 6,184
  • 2
  • 36
  • 54
0
votes
2 answers

Why does dynamic overload resolution not consider extension method candidates?

[TestFixture] public class ExpandoToMessageConverterTests { /// /// CanConvertEvent /// [Test] public void CanConvertEvent() { dynamic expandoEvent = new ExpandoObject(); expandoEvent.PropertyOne = "pROPERTYoNE"; …
AlexeiOst
  • 574
  • 4
  • 13
0
votes
1 answer

How to find value of one of root elements in xml using XElement? when the root elements have no child elements?

I would like to find the value of errorCode node using XElement. Please advise. 201498 XML…
0
votes
1 answer

Reading childelement to XElement in VB.NET

I've been trying to read an XML-file using VB.NET and after some (see 2-3 hours) googling and reading I've headed in somewhat the right direction, however now I'm at a stop and I can't find any answers that makes any sense to me. This is the XML I…
0
votes
2 answers

Unable to get xml node from XElement

I really need help with the where clause below. Consider this xml First Charles
FatAlbert
  • 4,890
  • 6
  • 22
  • 34
0
votes
1 answer

XElement.Save causes XmlUtf8RawTextWriter to throw an exception

The following exception was reported to have occurred on a client's machine: System.ArgumentException: '', hexadecimal value 0x1F, is an invalid character. at System.Xml.XmlUtf8RawTextWriter.InvalidXmlChar(Int32 ch, Byte* pDst, Boolean entitize) at…
Konrad Morawski
  • 8,307
  • 7
  • 53
  • 91