Click here to Skip to main content
15,125,890 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
<Object type="Book">
<Component id="123">
<Element id="123">
<Article id="1">
<Article id="2">

In the above XMl file if at least one Article element is available
then the Object Should be counted.

Similarly how to count if the file has large lines.
But the structure should be the above on.

How to do this

1 solution

Best way would be using linQ, something like

var count = XDocument

and to look for particular child see below.

IEnumerable<XElement> elements =
    from el in root.Elements("Element")
    where (string)el.Element("Article") <> ""
    select el;
sbarnes 1-Apr-14 1:53am
good succinct useable answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900