how to do find/count on xmlnodelist in c# - is xmlnodelist.childnodes.asqueryable() a good way?

860 views Asked by At

i have a legit XmlNodeList lets call it nodelist
i can call nodelist.ChildNodes and that works
i can also call nodelist.ChildNodes.AsQueryable()
but then when i try nodelist.ChildNodes.AsQueryable().Where(x=>x....) that fails

i have included

using System.Linq

but im kinda at a loss how to
1. find specific nodes
2. count the nodes that start with a specific key ie

<key1 attrib1="xxx">yyy</key1>

how many nodes are there with key="key1"

pls note: before i get yelled at for duplicate posting -
i have spent HOURS over a coupla days trying to figure out how to do this
and nothing on stack has been clear enough (for me anyways...)

thx - you guys are great

UPDATE: ok so whats interesting is that
even tho i got downgraded - nobody (immediately that is) had a solution to my exact question
which is how to do this with xmlnodelist
what people did have were alternate answers - all good
so it doesnt seem that xmlnodelist asqueryable does what the name implies

1) using xmlnode.selectnodes()
which a very good example can be found here
Select Xml Node using Linq to XML

2) XML class (see selected answer)

1

There are 1 answers

2
Volearix On BEST ANSWER

Attempt to put your XML into a custom class and query the custom class. It's more work, but man is the pay off worth it. Check out this question for info on how to do it.