c# - How to get elements value with Linq To XML -
How do I get the space_id value (720) from xml below to use Linq for XML?
I am reading but I think the namespace in XML is my obstacle.
& lt; R25: Space xmlns: r25 = "http://www.collegenet.com/r25" pubdate = "2009-05-05T12: 18: 18-04: 00" & gt; & Lt; R25: Space ID = "VE1QOjRhMDAyZThhXzFfMWRkNGY4MA ==" CRC = "" Status = "New" & gt; & Lt; R25: space_id & gt; 720 & lt; / R25: space_id & gt; & Lt; R25: SPACE_NAME & gt; SPACE_720 & lt; / R25: SPACE_NAME & gt; & Lt; R25: max_capacity & gt; 0 & lt; / R25: max_capacity & gt; & Lt; / R25: Space & gt; & Lt; / R25: Blanks & gt; Edit
Here's where I am:
Private Int GetIDFromXML (string xml) {XDocument xDoc = XDocument .Parse (xml); // hmmm ....}
You can also go (with slight variation) The code above which I think is a bit more readable)
XNamespace ns = "http://www.collegenet.com/r25"; String id = doc.Descendants (ns.GetName ("space_id"). Single (). Value;
Comments
Post a Comment