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

CSharp How to generate/parse multiple XElements from a string

I have an XElement and I need to add more elements to it from a string. The string contains multiple xml elements in it that I need to parse. I have tried both XDocument.Load and XElement.Parse but get errors. The contents of the file are as…
Shahid
  • 995
  • 3
  • 11
  • 24
0
votes
1 answer

How to name textboxes in MVC when passing XElement

I'm passing an XElement to my Edit view and want to have the usual HTML controls built for me and correctly named. The code I have is: ...
<%= Html.LabelFor(model =>…
Matt W
  • 11,753
  • 25
  • 118
  • 215
0
votes
1 answer

XML element - Formatting Tag

I am using new XElement("InstdAmt", "1000") However, I would like to add the currency in the first tag as shown below. How could I do this please? Only using the first tag new XElement("InstdAmt Ccy=EUR", "1000") so I can get this result…
user3274252
  • 57
  • 1
  • 6
0
votes
1 answer

Accessing elements of Unity (.config) file via XElement

I'm trying to write a code for getting element from .config file in this format:
nemo_87
  • 4,523
  • 16
  • 56
  • 102
0
votes
2 answers

Generating Xelement from list of object

My Code IList people=new List(); people.Add(new Person{Id=1,Name="Nitin"}); IList my=new List(){1,2,3}; IList your=new List(){1,2,3}; XElement xml = new…
Nitin Varpe
  • 10,450
  • 6
  • 36
  • 60
0
votes
1 answer

iterating XElements and then using XPath to extract child element values gets wrong value

I have two methods: the first one parses a xml string into some XElements (where the xml is a sequence of 'banana' elements) the second one extracts the value from a child 'id' element and returns it I have two alternative implementations of…
rogersillito
  • 869
  • 1
  • 10
  • 27
0
votes
2 answers

Can't remove an element in XML

I have XElement xDoc =

Dessuten møtte

Test!

When I try to remove en item with id = "item456" I get an…
podeig
  • 2,597
  • 8
  • 36
  • 60
0
votes
2 answers

xelement get same children nodes

I try get same children nodes value I want to get children regularly how to which the child belongs this value XElement element = XElement.Load(filedialog.FileName); var items = (from el in element.Descendants("property") select new { values…
teknodram
  • 11
  • 4
0
votes
2 answers

To add the element to List

Below is my code, List LValues = new List(); List IValues = new List(); List BValues = new List(); List[] data = new List[4]; List[] Data = new List[7]; float?…
Reshma
  • 864
  • 5
  • 20
  • 38
0
votes
1 answer

To convert XElement into int value,

I have my loop for childobjects as follows, List LValues = new List(); List IValues = new List(); List BValues = new List(); List[] data = new List[4]; float? Value_LfromList =…
Reshma
  • 864
  • 5
  • 20
  • 38
0
votes
1 answer

Problems to modify XElement after using Converter

I am creating a XElement via htmlconverter Class from OpenXML Powertools. XElement html = HtmlConverter.ConvertToHtml(doc, settings) Now I'm trying to add some new nodes like html.Element("head").Add(new XElement("link", new…
user3120053
  • 21
  • 1
  • 2
0
votes
1 answer

XDocument.Validate how to keep validating after errors?

i have a little problem and can´t figure out how to resolve it. I am Validating an XDocument against a schema and i get all the nodes which have error. But the Validation process doesnt go deeper after finding an error. …
0
votes
1 answer

One XElement from multiple streams

I need to create method which will concatenate multiple Xelements into one. I created below method: static void DoStuff(string IP, string login, string password, string port) { CommonMethods cm = new CommonMethods(); …
ironcurtain
  • 650
  • 9
  • 35
0
votes
1 answer

How to insert IEnumerable object into SQL Server table?

I have created below code to get Users from XML: string userName = "user"; string password = "password"; string uri = @"uri"; WebClient webClient = new WebClient(); webClient.Credentials = new…
ironcurtain
  • 650
  • 9
  • 35
0
votes
0 answers

Add attributes using XAttribute

I have a root XML which is like this: somevalue I need to add few customer related informaiton…
user1961100
  • 399
  • 3
  • 6
  • 15