i trying extract following values xml file: - - xml file represented follow:
<envelope_content> <documents> <document> <idx>1529</idx> <entity_priority>5</entity_priority> <cld_cod>magazine</cld_cod> <cld_desc>revues, magazine</cld_desc> <category>other</category> <tif_filename>revues, magazine_1529_si.tif</tif_filename> <comment /> <reject_messages /> <pages> <page> <pagidx>3375</pagidx> <position>1</position> <tifname>87771593-2fd4-4803-8736-e2c1a898a96b_002.tif</tifname> <jpegname>87771593-2fd4-4803-8736-e2c1a898a96b_001.jpg</jpegname> </page> <page> <pagidx>3376</pagidx> <position>2</position> <tifname>87771593-2fd4-4803-8736-e2c1a898a96b_004.tif</tifname> <jpegname>87771593-2fd4-4803-8736-e2c1a898a96b_003.jpg</jpegname> </page> <page> <pagidx>3377</pagidx> <position>3</position> <tifname>87771593-2fd4-4803-8736-e2c1a898a96b_006.tif</tifname> <jpegname>87771593-2fd4-4803-8736-e2c1a898a96b_005.jpg</jpegname> </page> <page> <pagidx>3378</pagidx> <position>4</position> <tifname>87771593-2fd4-4803-8736-e2c1a898a96b_008.tif</tifname> <jpegname>87771593-2fd4-4803-8736-e2c1a898a96b_007.jpg</jpegname> </page> </pages> </document> </documents> </envelope_content>
i using following c#code extract values
string xmltext = file.readalltext(f); xmldocument doc = new xmldocument(); doc.loadxml(xmltext); xmlnodelist parentnode = doc.getelementsbytagname("document"); list<string> p = new list<string>(); string classe = ""; foreach (xmlnode childrennode in parentnode) { classe = childrennode.selectsinglenode("cld_cod").innertext; }//end foreach
i managed extract value cld_cod can't manage extract values in "tifname"
how can iterate through nodes extract them?
thank you.
first of all, lot easier newer xml api linq-2-xml (xlinq).
var root = xelement.parse(xmltext); // or directly .load(filename) list<string> tifnames = root.descendants("tifname").select(e => e.value);
Comments
Post a Comment