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

Overwrite xml file on network drive

I want to edit a xml file. I can open, edit and save (overwrite) the file on the local drive. I can open and edit the file on the network drive. I also can save it to a new path, but I cant overwrite the file. Dim localPath As String =…
Andi
  • 1
  • 1
0
votes
1 answer

C#: How to get all descendant XElements including root element of an XElements elegantly?

I am trying to get all descendant XElements including root element of an XElement according to presence of specific attribute. My not very nice attempt: var myXElements = form.FormData.Descendants().Where(e => e.Attributes().Where(a => a.Name ==…
0
votes
1 answer

In a Xml how to iterate within node which is having similar property in c#

I have a xml as below: In this i have to find value of Generic Field "FetchItems" creatorSalesRepId 12345
p995
  • 49
  • 8
0
votes
1 answer

How to add if condition in inside XElement (XML Serializer)

var xmlfromLINQ = new XElement("BarList", from c in BarList select new XElement("Bar", new XElement("Property1", c.Property1), new XElement("Property2", c.Property2) )); How To…
CoderGreat
  • 11
  • 2
0
votes
2 answers

How make line break when working with Xelement

Hello and sorry if question is strange and sorry for bad english. My code: xws.OmitXmlDeclaration = true; using (XmlWriter xw = XmlWriter.Create(sb, xws)) { string lb = "\r\n"; XElement I11 = new XElement("I11", lb, …
Don
  • 3
  • 2
0
votes
1 answer

Add Attribute to Existing XML Element in VB.Net

How can I add an attribute to an existing XML element in VB.Net? I open a file then I read the XML data from it: Dim xmldoc As New XmlDataDocument() Dim xmlnode As XmlNodeList Dim source As String = $"C:\sample.xml" Dim fs As New FileStream(source,…
Marwan مروان
  • 2,163
  • 8
  • 30
  • 40
0
votes
2 answers

How to Parse XML without throwing exceptions on comments in file

I basically have this Code in VB.NET xmlline = "etc.. " Dim XMLInput As XElement XMLInput = XElement.Parse(xmlline) and the comment is throwing and exception however i place it. As both "double root…
0
votes
1 answer

XElement C#: How to change the value of XElement?

I have an element that has some value like: Some Text How do I keep the "I" element but change the "Some Text" in the Element Tag?
redoc01
  • 2,107
  • 5
  • 32
  • 64
0
votes
2 answers

NullRefernceException when adding XElement to a XDocument

I have the following .xml file: Resolver1 Locale localhost 8082
Rick
  • 13
  • 3
0
votes
1 answer

Get value between xml tags having a "title" as value in name attribute?

I'm currently importing webparts using a file upload control containing collection of webPartDescription (XML)
0
votes
1 answer

Using Linq to Get Lat/Lon from Bing Maps REST Service

I'm calling the Bing Maps Service to return some XML here: http://dev.virtualearth.net/REST/v1/Locations/Encoded_Address?o=xml&key=Maps_Key For the life of me, I can't seem to get the Longitude and Latitude using Linq! It always returns null.…
Armstrongest
  • 15,181
  • 13
  • 67
  • 106
0
votes
1 answer

Trying to count named XML elements filtered by parent element name and index value

I have been just about managing to manipulate XML in VB.net but I've run into a problem I'm really struggling with, so I'm reaching out for a little guidance please?! With this example XML...
Darryl
  • 11
  • 4
0
votes
1 answer

LinQ to XML access elements and their values

Sorry for my bad english... I try to get an enum of the elements "Member" and their values from my example XML-Code. This Code is generated by an external program. i shrink this xml-file to an example.
Echnaton
  • 3
  • 2
0
votes
2 answers

Delete XElement based on attribute

I'm still playing around with xml. Now I have a file that looks like this: some text here some text here
Dude-Dastic
  • 380
  • 1
  • 5
  • 13
0
votes
1 answer

How to extract xml value in c# Xml. Linq

This is my xml: I need to extract date value & num value I tried this but doesn't work and returns to me null. using System.Xml.Linq; var…