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

Setting properties for object only when present in database

I have an object that is supposed to describe some customer with these values: { public class CustomerDescription { public string FirstName { get; set; } = ""; public string LastName { get; set; } = ""; public string…
PalBo
  • 2,203
  • 3
  • 22
  • 43
0
votes
1 answer

In XElement WriteTo method force XmlWriter to use a prefix for a child element with a defined xmlns attribute

I know that the question looks very similar to many asked here before, yet I could not find any satisfactory answers to it. I keep rss items captured from external feeds in a database and should be able to generate feeds of my own. Consider this…
0
votes
1 answer

XElement ReplaceWith

I would like to replace a specific node with string. It successfully replace the node but instead of "
", it appear "<div>" What should I do to make it into "
"? I have tried XElement.Parse but it will give me error as I replace node…
Yin How
  • 89
  • 1
  • 7
0
votes
1 answer

How to read xml in c# with XElement?

I have this xml false
omega
  • 40,311
  • 81
  • 251
  • 474
0
votes
2 answers

Use a "for" loop in XElement

I'm trying to create a converter CSV to XML. The XML files might not have always the same number of fields, so i'm trying to get this number and then use it to create the elements string[] source = new string[] { ligne }; …
Laïla B
  • 11
  • 3
0
votes
1 answer

Xelement attribute value loses its encoding

Suppose we have this code: string actualvalue = "<a>"; string abc = ""; XElement item2 = XElement.Parse(abc); foreach (var item in item2.Descendants("secondnode")) { …
Ahtesham ul haq
  • 319
  • 1
  • 5
  • 14
0
votes
1 answer

LINQ to XML. How to query List with Linq recursively

I'm generating XML file from structs. Some struct members are in List type. I'm using linq queries but I'm stuck at some level. My structs are like this: public struct Project { public string name; public List classes; } public…
lycian
  • 3
  • 1
0
votes
0 answers

Best way to iterate through all XML elements and attributes

I want to know which is the best way to iterate through XML file and get all elements(name & value) and attributes(name & value) keep in mind the root and elements names. I would like to get a result like this per each element: Id = 1 Nombre = Test…
Cristian18
  • 220
  • 3
  • 12
0
votes
1 answer

Convert Dictionary to xml through exception "Name cannot begin with the '1' character, hexadecimal value 0x31. "

Here is the code that I tried to convert Dictionary to xml string. XElement xml_code = new XElement("root", myDictionary.Select(item => new XElement(item.Key, item.Value))); Above code throw the error Name cannot begin with the '1' character,…
Mannan Bahelim
  • 1,289
  • 1
  • 11
  • 31
0
votes
1 answer

C# : Get Specific Element Before another Element with Linq

Consider the following snippet from an XSD:
Rico Strydom
  • 537
  • 1
  • 6
  • 26
0
votes
1 answer

XElement read with multiple namespaces; detect which namespaces are used

I have an xml document that uses multiple namespaces:
Harald Coppoolse
  • 28,834
  • 7
  • 67
  • 116
0
votes
0 answers

How do I insert an XML 'item' node at specific position in nested list C#

I have a program that builds XML line by line pulling the content from MS Word docs. The XML can contain nested bullet lists like that shown below. I need the ability to be able to specify which list level my item needs to be inserted. So this could…
Daedalus
  • 539
  • 2
  • 6
  • 16
0
votes
1 answer

How to Read XML Document containng same groups

I have one xml document and I want to read some data from that. The XML document is like below :- FYI - This is the actual XML file syntax used in our application. Now I want to read the data from only one group say group name="AutoSaveView". How…
Bhupesh
  • 35
  • 7
0
votes
1 answer

How to properly access/modify an attribute in XElement object

I have some code that reads in a nicely formatted XML file. It wraps each XElement it reads into my object (ScriptEventNode) where I have some fields to allow the caller to change some of the Element and Attribute values that matter to us. I also…
kingtermite
  • 55
  • 2
  • 9
0
votes
1 answer

Showing XElement in Wpf

I have Question. This has a property Body which is an XElement. How Can I show This as Text in a Wpf application?
Stef Dhollander
  • 91
  • 1
  • 1
  • 3