ndlopez / NowPlaying

Stream Player for ThirdRock Radio
0 stars 0 forks source link

XML attrib #2

Closed ndlopez closed 1 year ago

ndlopez commented 1 year ago

Cant parse XML content attributes correctly. The following is a snippet from StackOver to access some XML attrib descendants.

`var xml = "<Setting ..."; var doc = XElement.Parse(xml); int i; // for int parse var q = from node in doc.Descendants("PatientFieldSetting") let name = node.Attribute("PatientName") let length = node.Attribute("PatentFieldLength") select new { Name = (name != null) ? name.Value : "", Length = (length != null && Int32.TryParse(length.Value, out i)) ? i : 0 };

foreach (var node in q) { Console.WriteLine("Name={0}, Length={1}", node.Name, node.Length); }`

ndlopez commented 1 year ago

The above snippet doesn't work. I tried another piece of sample code that loops over all the nested *bastard childs and appends them to an array. I actually used an index to find the desired url and it finally worked.