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
votes
2 answers

Replaceing a complete node in an existing xelement

I have an xElement data Need to replace item node with another node . How can we achieve this? I just need to replace item node with some other node say I want output as
-1
votes
3 answers

how to use create a xml document with Xelement

I am trying to create a xml document using Xelement. I have a List of 2 objects, Data and Products. each has a list of objects. the xml document needs to be setup like this 1432 45666
texas697
  • 5,609
  • 16
  • 65
  • 131
-1
votes
3 answers

How to find and change inner text of xml elements? C#

I have a following xml file. I need to change the inner text of ANY tag, which contains the value «Museum», or just a tag for a start: ¾ Direction to move
StepUp
  • 36,391
  • 15
  • 88
  • 148
-1
votes
1 answer

xmlns="something" - must be in parent nod

I have a problem. Can't name XAttribute like this: XAttribute("xmlns", nss.NamespaceName) XNamespace ns = "urn:hl7-org:v3"; XNamespace nsVoc = "urn:hl7-org:v3/voc"; new XElement("ClinicalDocument", new XAttribute(XNamespace.Xmlns +…
-1
votes
1 answer

Multiple values in XElement

I must convert csv to xml and validate with xsd. My problem is, that my outpot is not the same as xsd. I don't now how to do it.. :( This is my xsd code:
-1
votes
2 answers

Why does .Any() not work in this specific XElement extension method?

I made a simple method that returns a string value from a specific node (or returns null if it doesn't exist). private static string getValueIfExist(XElement element, string nodeName) { return element.Elements(nodeName).Any() ?…
CameO73
  • 123
  • 1
  • 5
-1
votes
3 answers

Parse XML with Child Nodes

I have an XML file which returns a list of products with colors and inventory for each color. What is the best method to loop through this data only returning inventory by color for a specific product i.e. PL-0223? Here is the data.
Jason Miller
  • 253
  • 1
  • 3
  • 10
-1
votes
1 answer

how to write a element in a xml file

I'm writing a xml file, but when i started to write elements, it comes with some errors, and when i try to read the xml fil by code, it can't find these elements.
Gaute Haugen
  • 103
  • 1
  • 2
  • 15
-1
votes
1 answer

How to set a value to an empty XElement?

How can I set a value to the Url XElement inside Google?
user990635
  • 3,979
  • 13
  • 45
  • 66
-1
votes
1 answer

How do you write an XElement to file asnychronously without hitting the "multiple root nodes" issue?

I'm using XML to mock up a database and, when loading it with dummy data, I keep getting an error telling me that there are multiple root elements. Upon opening the file I can confirm that multiple root elements are being written to the file, but…
elucid8
  • 1,412
  • 4
  • 19
  • 40
-1
votes
1 answer

"Object reference not set to an instance of an object", when the variable is defined?

EDIT: I found the error. I was setting the elements in the wrong place, and then calling their XPath in the right (different) place. I'm trying to get values of XML elements inside of another XElement, and when I try to get the value using XPath,…
Dominoed
  • 123
  • 3
  • 15
-1
votes
1 answer

how to find an element value in xml when we have multiple namespaces

I want to get the value of the element rsm:CIIHExchangedDocument/ram:ID But I have problem with multiple namespaces, and null values (I can not know if requested element exists) It can be achieved this way: XElement invoice =…
katanuska
  • 3
  • 1
-1
votes
1 answer

Dynamic Nested XElements

I wish to create an XML and this will include something as follows :- 1 Group1
JMon
  • 3,387
  • 16
  • 63
  • 102
-1
votes
1 answer

Adding Dynamic Content to an XML Document

can you please help me with this code. Thank you. In this code under the word Today a warning : an embedded expression cannot be used here Dim doc = _ New XElement("Books", _ New XElement("Book", _ New XAttribute("ISBN", "0000000000001"), _ New…
-2
votes
3 answers

How to check if first XML node exist?

I have the following XML: node1 valuenode2 value I'd like to check if Root is the first node. If so, I then want to get the values for the to child nodes. This XML is inside of an XElement. I've tried…
4thSpace
  • 43,672
  • 97
  • 296
  • 475
1 2 3
58
59