I am following a web service that will return an XElement. The service creates an excel database from a database I have created an XML document for the local test service which creates a list of XML elements as a simulator. I want to choose one of these in LINQ and return to XML.
So I have an XML document:
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Customers & gt; & Lt; Customer Ordercode = "GCT / 12345A" & gt; & Lt; Title & gt; Miss & lt; / Title & gt; & Lt; The first letter of the name & gt; & Lt; / First letter of the name & gt; & Lt; Surname & gt; Customers & lt; / Nickname & gt; ... & lt; / Customer & gt; & Lt; Customer Ordercode = "GCT / 12346A" & gt; & Lt; Title & gt; Mrs. & lt; / Title & gt; & Lt; The first letter of the name & gt; A & lt; / First letter of the name & gt; & Lt; Surname & gt; Other & lt; / Nickname & gt; ... & lt; / Customer & gt; & Lt; / Customers & gt; And using LINQ, I want to select one of the client elements by order code attribute. I just basically remove the InnerXML client node and it has to be returned. I tried to parsize this way:
XElement xcust = (XElement) (in xdocument.Descendants ("Customer") in where c.Attribute ("ordercode") == Returns Struggle. ). Single (); But it was not working. I also tried:
New excelment ("customer", [similar LINQ query]); I'm guessing that I should be inquired about any of the selected customer's INAxml, but I'm not sure how to do this. As most people just parse the XML directly into the required items (which I am simulating the feedback from a remote service, I can not do it) I do not have much information which can only be found if I return the raw element It's because I think it's a bit of a use of a torrent case.
You must check the value property of the attribute:
XElement Xcust = (XElement) (c from doc.Descendants ("Customer") where c.Attribute ("ordercode") .main == Selection of Strader c). Single (); You can also leave the cast in XElement.
Comments
Post a Comment