Questions tagged [xattribute]

The xattribute tag is for questions about the C# (System.Xml.Linq) XAttribute class.

One MSDN reference page for the class is Xattribute Class (System.Xml.Linq).

50 questions
0
votes
0 answers

Adding new xElement after ALL found Descendants

I have an xDocument with multiple various xElements. I can successfully find a specific xElement by searching via it's xAttributes & then Add a new xElement after it using the code below: xDocument.Descendants("td").LastOrDefault(e =>…
1cm69
  • 177
  • 2
  • 16
0
votes
2 answers

How does one increment/update integer value of an XML Attribute in C# (XAttribute)?

TL;DR: If I have an XAttribute of NumFruits in an XElement, how can I increment/update the value from 0 to 1,2,3... ? The issue: When I attempt to increment the XAttribute like so: basket.Attribute("numFruits").Value += 1 the result for…
matrixanomaly
  • 6,627
  • 2
  • 35
  • 58
0
votes
2 answers

Xattribute in a loop in c#

public override XElement createXmlElement() { XElement XShape = new XElement("Shape", new XAttribute("Name", "freeline"), new XElement("Pen_Details", new XAttribute("PenColor", this.PenColor.ToArgb().ToString("X")), new…
Makam
  • 1
  • 1
0
votes
1 answer

How to add XML namespace values using XElement, XAttribute

Here is the desired (required) output:
0
votes
1 answer

Get another attribute on the same element by searching another attribute

This might be the simplest question for that i appologise. This is part of my xml. What i want to get is the attribute "Value" based on another attribute "ItemOID". IE when ItemOID="I_MEDIC_HISTORY_INDICATION" what is the value.
user3276223
  • 59
  • 1
  • 8
0
votes
2 answers

XElement Automatically Having xmlns attribute

Dim soapEnvelope As XElement = New XElement(soap + "Envelope", New XAttribute(XNamespace.Xmlns + "soap", soap.NamespaceName), New XAttribute(soap + "encodingStyle",…
HelpASisterOut
  • 3,085
  • 16
  • 45
  • 89
0
votes
1 answer

LINQ to XML: Don't Create XAttribute if value is DBNull.Value

I am querying a database using C# and creating a DataTable. From this DataTable I am using LINQ to XML to create an XML file. My problem is that for null columns in the data table, when I call SetAttributeValue on an element, it creates a blank…
0
votes
1 answer

XAttribute implementing IComparable during tests, but not when live

I have some code below that is throwing an exception in integration environments but not in my unit tests. Basically I'm sorting some XML elements (linq-2-sql XElement) by an attribute value. All the nodes have the attribute…
Frank Schwieterman
  • 24,142
  • 15
  • 92
  • 130
0
votes
1 answer

XML Concatenate an string to set as an XAttribute

I am reading in a CSV file to convert to XML format. How do I concatenate a fixed string before one of the fields. In this example i need to attach "domain\" to the username string[] csvString = File.ReadAllLines("file.csv"); XElement…
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
0
votes
4 answers

Problem Reading XElement Attribute

Anyone knows why this xpath expression "catzero/@id" is not working on this xml document = XDocument.Load("file.xml"); var product = document.XPathSelectElements("//product", nameSpaceResolver).First(); var category = ((IEnumerable)…
h3n
  • 5,142
  • 9
  • 46
  • 76
0
votes
1 answer

Controling XElement Attribute Namespace Names

I'm in the process of building an export engine that will take our company's data and export it as XML based on the pattern provided in our database. One of the exports I need to implement must have the xsi:nil="true" attribute added to the element…
KevinK
  • 1
  • 1
0
votes
2 answers

searching for an unnamed nested XElement by a specific XAttribute

Here is what my XML looks like (Yes, I know the XML is ugly). I'm trying to search and remove any nodes from this XDocument that have the isConstField attribute set to "Y" without iterating through each individual XElement.
0
votes
2 answers

How to convert XML to Xelement?

string queryText = string.Format(@" 3
0
votes
3 answers

Add attribute without name and value?

Whether XML element attribute name can be empty: I am getting an exception I cant to load this. Is this…
Aravind Srinivas
  • 251
  • 3
  • 8
  • 15