Convert Specific variable in XML to string C#

Zec

New Member
I need to convert a specific part of an XML file to string, with the data in it varying. eg. I have an xml file with this portion in it: \[code\]-<root>-<Data><1>data</1>\[/code\]and I want to only convert that line to a string, not the entire file. This, I know how to do. My issue is that the data in "1" will change depending on the circumstances, and I still want to be able to use the same program to convert it regardless of what the data in "1" reads.to read the "1" line without verying data I know I can use:\[code\] var xml = "<root><Data><1>data</1></Data></root>"; var xmlString = XElement.Parse(xml).Descendants("1").FirstOrDefault().Value;\[/code\]but I don't know how to do it with the contents of "1" changing.
 
Back
Top