[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Perl: Brug af pakken XML::DOM



Hej

Jeg har lidt problemer med at bruge pakken XML::DOM:
Jeg har en XML fil der se således ud:

<A>
  <B>
    <C>
      ...
    </C>
    <C>
      ...
    </C>
    <C>
      ...
    </C>
  </B>
</A>

Og jeg vil gerne have fat i de 3 nodes C (og ikke elementerne), midt bud
på dette er følgende:

use XML::DOM;

my $parser = new XML::DOM::Parser;
my $doc = $parser->parsefile ("test.xml");
$node = $doc->getDocumentElement()->getElementsByTagName("B")->item(0);
$metaList = $node->getElementByTagName("metaEntry");

Problemet i ovenstående kode er at det som ligger i $node ikke er en node,
men et element. Jeg mener ikke at det burde være et problem da
XML::DOM::Element arver fra XML::DOM::Node.
På trods af at classen XML::DOM::Element arver fra XML::DOM::Node kan jeg
ikke få lov til at kalde metoden getElementByTagName der ligger i
XML::DOM::Node

Er der en speciel syntaks til at kalde metoder i en ned arvet klasse eller
er der en metode til at konverter/carste en XML::DOM::Element til en
XML::DOM::Node

MVH.
Allan W. Nielsen



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:44 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *