Hi guys
Not very active programming these days, but I have a question about one script using XML::Lib
XML Looks like this, I need to get type, uri and href from "target" using XML::Lib.
dmazzini
GSM/UMTS System and Telecomm Consultant
Not very active programming these days, but I have a question about one script using XML::Lib
XML Looks like this, I need to get type, uri and href from "target" using XML::Lib.
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<tags size="3" uri="XXXXXX">
<tag href="ZZZZZZZZ" uri="DDDDDDDD">
<id>2752699</id>
<name>MYNAME</name>
<type>public</type>
<targets uri="ZZZZZZZ">
<target type="I WANT THIS" uri="I WANT THIS" href="I WANT THIS"/>
<target type="I WANT THIS" uri="I WANT THIS" href= I WANT THIS"/>
</targets>
</tag>
Code:
my $xs = XML::LibXML->new();
my $doc = $xs->parse_string($xmldata);
my $xc = XML::LibXML::XPathContext->new($doc);
my $tagList = $xc->find('/tags/tag');
foreach my $tag($tagList->get_nodelist) {
my $tagHref = $tag->XML::LibXML::Element::getAttribute('href'); # OK
my $tagUri = $tag->XML::LibXML::Element::getAttribute('uri'); # OK
my $tagId = $tag->XML::LibXML::Element::getChildrenByTagName('id'); # Ok
my $name = $tag->XML::LibXML::Element::getChildrenByTagName('name'); # Ok
my $type = $tag->XML::LibXML::Element::getChildrenByTagName('type'); Ok
my $target = $tag->XML::LibXML::Element::getChildrenByTagName('target'); Not Ok, How to?
}
dmazzini
GSM/UMTS System and Telecomm Consultant