I have an XML document :
<Results>
<ResultSet>"nothing special" Description="More of nothing" type="system"
<Results1>
<time>
<Body>type="system" datatype="int"</Body>
<att2>type="session" datatype="float"</att2>
</Result>
<Result>
<ID>type="system" datatype="int"</ID>
<Stuff>type="session" datatype="float"</Stuff>
</Result>
<Result>
<att1>type="system" datatype="int"</att1>
<att2>type="session" datatype="int"</att2>
</Result>
</Results1>
<Results2>
<time>
<att1>type="session" datatype="int"</att1>
<att2>type="system" datatype="float"</att2>
</Result>
<Result>
<ID>type="system" datatype="float"</ID>
</Result>
</Results2>
</ResultSet>
</Results>
I would like to get the path for each type = "session"
in the document in a list using C#. For the moment, I have a function to get the path getPath
. But I have absolutely no idea about how to search in ALL the XML no matter the node.
I'm using LINQ to XML and this is what I have for the moment :
List<string> pathList = new List<string>();
IEnumerable<XElement> path =
from element in doc.Elements(/*I don't know*/)
where (string)element.Attribute("type") == "session"
select element;
foreach (XElement element in path){
pathList.Add(getPath(element));
}
No comments:
Post a Comment