Loading ...
Sorry, an error occurred while loading the content.

How to use Module

Expand Messages
  • Anil KUMAR BN
    Hi My knowledge in perl is only for search and replace, foreach loops some basic stuffs. I don t know how to use module. I have tried this example in
    Message 1 of 1 , Oct 14, 2008
    • 0 Attachment
      Hi

      My knowledge in perl is only for search and replace, foreach loops some
      basic stuffs. I don't know how to use module. I have tried this example in
      XML::XPath module, I have pasted the perl file and xml file for your
      reference.



      Here my question is how to find preceding sibling or following sibling, is
      it possible by using modules.



      I am new to using this modules, please give some hints how to start using
      modules.



      Regards

      Anil Kumar

      Pperl file

      use XML::XPath;

      use XML::XPath::XMLParser;



      my $xp = XML::XPath->new(filename => 'xml.xml');



      #my $nodeset = $xp->find('/employees/employee/sex'); # find all
      paragraphs

      my $getNodeText = $xp->find('/employees/employee/name'); # find all
      paragraphs



      foreach my $node ($getNodeText->get_nodelist) {

      print XML::XPath::XMLParser::as_string($node),

      "\n";

      }

      Xml.xml file

      <?xml version='1.0'?>

      <employees>

      <employee>

      <name>John Doe</name>

      <age>43</age>

      <sex>M</sex>

      <department>Operations</department>

      </employee>

      <employee>

      <name>Jane Doe</name>

      <age>31</age>

      <sex>F</sex>

      <department>Accounts</department>

      </employee>

      <employee>

      <name>Be Goode</name>

      <age>32</age>

      <sex>M</sex>

      <department>Human Resources</department>

      </employee>

      </employees>



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.