Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

gellyfish's scratchpad

by gellyfish (Monsignor)
on Jun 03, 2004 at 22:37 UTC ( #360552=scratchpad: print w/ replies, xml ) Need Help??

*****************************

Assuming XML is in greet.xml:

use XML::XPath; + my $xp = XML::XPath->new(filename => 'greet.xml'); + print $xp->findvalue('//greeting/text()')->value();

*******************************

use XML::LibXML; my $parser = XML::LibXML->new(); + my $doc = $parser->parse_string(<<'EOT'); <?xml version="1.0" encoding="UTF-8"?> <PathXml> <Paths> <path1 a="C:/ashwani/projects/path1"/> <path2 b="C:/ashwani/projects/path2"/> <path3 c="C:/ashwani/projects/path3"/> </Paths> </PathXml> EOT + foreach my $node ($doc->findnodes('//Paths/*') ) { print $node->nodeName(), ($node->attributes())[0]->nodeValue(),"\n" +; }
Installing XML-LibXML:
C:\Documents and Settings\jstowe-admin>install http://theoryx5.uwinnip +eg.ca/ppms /XML-LibXML.ppd 'install' is not recognized as an internal or external command, operable program or batch file. C:\Documents and Settings\jstowe-admin>ppm install http://theoryx5.uwi +nnipeg.ca/ ppms/XML-LibXML.ppd ==================== Install 'XML-NamespaceSupport' version 1.09 in ActivePerl 5.8.7.815. ==================== Installing C:\Perl\html\site\lib\XML\NamespaceSupport.html Installing C:\Perl\site\lib\XML\NamespaceSupport.pm Successfully installed XML-NamespaceSupport version 1.09 in ActivePerl + 5.8.7.815 . ==================== Install 'XML-SAX' version 0.14 in ActivePerl 5.8.7.815. ==================== Installing C:\Perl\html\site\lib\XML\SAX.html Installing C:\Perl\html\site\lib\XML\SAX\Base.html Installing C:\Perl\html\site\lib\XML\SAX\DocumentLocator.html Installing C:\Perl\html\site\lib\XML\SAX\Exception.html Installing C:\Perl\html\site\lib\XML\SAX\Intro.html Installing C:\Perl\html\site\lib\XML\SAX\ParserFactory.html Installing C:\Perl\html\site\lib\XML\SAX\PurePerl.html Installing C:\Perl\html\site\lib\XML\SAX\PurePerl\Reader.html Installing C:\Perl\site\lib\XML\SAX.pm Installing C:\Perl\site\lib\XML\SAX\Base.pm Installing C:\Perl\site\lib\XML\SAX\DocumentLocator.pm Installing C:\Perl\site\lib\XML\SAX\Exception.pm Installing C:\Perl\site\lib\XML\SAX\Intro.pod Installing C:\Perl\site\lib\XML\SAX\ParserFactory.pm Installing C:\Perl\site\lib\XML\SAX\placeholder.pl Installing C:\Perl\site\lib\XML\SAX\PurePerl.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\DebugHandler.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\DocType.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\DTDDecls.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\EncodingDetect.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\Exception.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\NoUnicodeExt.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\Productions.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\Reader.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\UnicodeExt.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\XMLDecl.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\Reader\NoUnicodeExt.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\Reader\Stream.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\Reader\String.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\Reader\UnicodeExt.pm Installing C:\Perl\site\lib\XML\SAX\PurePerl\Reader\URI.pm Successfully installed XML-SAX version 0.14 in ActivePerl 5.8.7.815. could not find ParserDetails.ini in C:/Perl/site/lib/XML/SAX Unable to recognise encoding of this document at C:/Perl/site/lib/XML/ +SAX/PurePe rl/EncodingDetect.pm line 96, <$__ANONIO__> line 70. Unable to recognise encoding of this document at C:/Perl/site/lib/XML/ +SAX/PurePe rl/EncodingDetect.pm line 96, <$__ANONIO__> line 79. ==================== Install 'XML-NamespaceSupport' version 1.09 in ActivePerl 5.8.7.815. ==================== could not find ParserDetails.ini in C:/Perl/site/lib/XML/SAX Unable to recognise encoding of this document at C:/Perl/site/lib/XML/ +SAX/PurePe rl/EncodingDetect.pm line 96, <CLIENT> line 85. Successfully installed XML-NamespaceSupport version 1.09 in ActivePerl + 5.8.7.815 . ==================== Install 'XML-LibXML-Common' version 0.13 in ActivePerl 5.8.7.815. ==================== Installing C:\Perl\site\lib\auto\XML\LibXML\Common\Common.bs Installing C:\Perl\site\lib\auto\XML\LibXML\Common\Common.dll Installing C:\Perl\site\lib\auto\XML\LibXML\Common\Common.exp Installing C:\Perl\site\lib\auto\XML\LibXML\Common\Common.lib Installing C:\Perl\html\site\lib\XML\LibXML\Common.html Files found in blib\arch: installing files in blib\lib into architectu +re depende nt library tree Installing C:\Perl\site\lib\XML\LibXML\Common.pm The library libxml2.dll is needed to complete the installation, and should be placed in a directory somewhere in your PATH environment variable. I can fetch and install this for you, if you don't already have it. Fetch libxml2.dll? [yes] yes Fetching http://theoryx5.uwinnipeg.ca/ppms/scripts/libxml2.dll ... do +ne! Where should libxml2.dll be placed? [C:\Perl\bin] libxml2.dll has been successfully installed to C:/Perl/bin Successfully installed XML-LibXML-Common version 0.13 in ActivePerl 5. +8.7.815. ==================== Install 'XML-LibXML' version 1.58 in ActivePerl 5.8.7.815. ==================== Installing C:\Perl\site\lib\auto\XML\LibXML\LibXML.bs Installing C:\Perl\site\lib\auto\XML\LibXML\LibXML.dll Installing C:\Perl\site\lib\auto\XML\LibXML\LibXML.exp Installing C:\Perl\site\lib\auto\XML\LibXML\LibXML.lib Installing C:\Perl\html\site\lib\XML\LibXML.html Installing C:\Perl\html\site\lib\XML\LibXML\Attr.html Installing C:\Perl\html\site\lib\XML\LibXML\Boolean.html Installing C:\Perl\html\site\lib\XML\LibXML\CDATASection.html Installing C:\Perl\html\site\lib\XML\LibXML\Comment.html Installing C:\Perl\html\site\lib\XML\LibXML\Document.html Installing C:\Perl\html\site\lib\XML\LibXML\DocumentFragment.html Installing C:\Perl\html\site\lib\XML\LibXML\DOM.html Installing C:\Perl\html\site\lib\XML\LibXML\Dtd.html Installing C:\Perl\html\site\lib\XML\LibXML\Element.html Installing C:\Perl\html\site\lib\XML\LibXML\Literal.html Installing C:\Perl\html\site\lib\XML\LibXML\Namespace.html Installing C:\Perl\html\site\lib\XML\LibXML\Node.html Installing C:\Perl\html\site\lib\XML\LibXML\NodeList.html Installing C:\Perl\html\site\lib\XML\LibXML\Number.html Installing C:\Perl\html\site\lib\XML\LibXML\Parser.html Installing C:\Perl\html\site\lib\XML\LibXML\PI.html Installing C:\Perl\html\site\lib\XML\LibXML\SAX.html Installing C:\Perl\html\site\lib\XML\LibXML\Text.html Installing C:\Perl\html\site\lib\XML\LibXML\SAX\Builder.html Installing C:\Perl\html\site\lib\XML\LibXML\SAX\Generator.html Files found in blib\arch: installing files in blib\lib into architectu +re depende nt library tree Installing C:\Perl\site\lib\XML\LibXML.pm Installing C:\Perl\site\lib\XML\LibXML.pod Installing C:\Perl\site\lib\XML\LibXML\Attr.pod Installing C:\Perl\site\lib\XML\LibXML\Boolean.pm Installing C:\Perl\site\lib\XML\LibXML\CDATASection.pod Installing C:\Perl\site\lib\XML\LibXML\Comment.pod Installing C:\Perl\site\lib\XML\LibXML\Document.pod Installing C:\Perl\site\lib\XML\LibXML\DocumentFragment.pod Installing C:\Perl\site\lib\XML\LibXML\DOM.pod Installing C:\Perl\site\lib\XML\LibXML\Dtd.pod Installing C:\Perl\site\lib\XML\LibXML\Element.pod Installing C:\Perl\site\lib\XML\LibXML\Literal.pm Installing C:\Perl\site\lib\XML\LibXML\Namespace.pod Installing C:\Perl\site\lib\XML\LibXML\Node.pod Installing C:\Perl\site\lib\XML\LibXML\NodeList.pm Installing C:\Perl\site\lib\XML\LibXML\Number.pm Installing C:\Perl\site\lib\XML\LibXML\Parser.pod Installing C:\Perl\site\lib\XML\LibXML\PI.pod Installing C:\Perl\site\lib\XML\LibXML\SAX.pm Installing C:\Perl\site\lib\XML\LibXML\SAX.pod Installing C:\Perl\site\lib\XML\LibXML\Text.pod Installing C:\Perl\site\lib\XML\LibXML\SAX\Builder.pm Installing C:\Perl\site\lib\XML\LibXML\SAX\Builder.pod Installing C:\Perl\site\lib\XML\LibXML\SAX\Generator.pm Installing C:\Perl\site\lib\XML\LibXML\SAX\Parser.pm Successfully installed XML-LibXML version 1.58 in ActivePerl 5.8.7.815 +. C:\Documents and Settings\jstowe-admin>
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2014-11-29 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls