Hello! I'm trying to parse an XML for which I have to find an extract only specific childnodes. The XML file is below:
From the above XML file, I need to extract only the LI_Title nodes where Header = "Include". There can be 1 or many LI_Titles in an xml file and many such sections<Aritcle> <Main> <Sect> <H4>Include</H4> ..... <P1> This is the criteria</P1> <L> <LI> <LI_Label>1.</LI_Label> <LI_Title>Critera 1</LI_Title> </LI> <LI> <LI_Label>2.</LI_Label> <LI_Title>Critera 2</LI_Title> </LI> <LI> <LI_Label>3.</LI_Label> <LI_Title>Critera 3</LI_Title> </LI> <LI> <LI_Label>4.</LI_Label> <LI_Title>Critera 3</LI_Title> </LI> </Sect> </Main> </Article>
I've come up with the following to identify the nodes.But I'm not sure how I can just pull out the LI_Title nodes.So, hoping for some help here.
$dom = $parser->parse_file($file); my $expr = ('//Article//Main//Sect//H3[contains(.,"Include")]|//Articl +e//Main//Sect//H4[contains(.,"Include")]|//Article//Main[contains(.," +Include")]//*[name()="LI"]'); my @nodes=$dom->findnodes($expr); foreach $nod(@nodes) { print "element: ".$nod->nextNonBlankSibling(); }
Thanks in advance.-madbee
In reply to Extracting specific childnodes by madbee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |