c# - get xml node by order -
i have xml file like:
<?xml version="1.0" encoding="utf-8" ?> <config> <metadataformconfig fieldinternalname="test"> <tabs> <tab title="a c" order="1"> <showparentterm>a</showparentterm> <showparentterm>b</showparentterm> <showparentterm>c1</showparentterm> </tab> <tab title="d e" order="2"> <showparentterm>d</showparentterm> <showparentterm>e</showparentterm> </tab> </tabs> </metadataformconfig> </config>
i want tab element order. if changed tab title="a c" order 2 want node "d e" first "a c"
can 1 me how this?
you can linq xml:
xdocument doc = xdocument.load(@"test.xml"); var tabs = doc.descendants("tab") .orderby(t => convert.toint32(t.attribute("order").value)) .tolist();
this select list of tab elements ordered value of order
attribute.
Comments
Post a Comment