in reply to perl xpath extraction
i tried extracting the "editor" for the specified xml file using the XPath tutorials as suggested.Im supposed to do it with XPATH only . cannot use TWIG. the xml file is
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE TEI.2 SYSTEM "tei-epidoc.dtd" > <TEI.2 lang="eng" id="eAla001"> <teiHeader status="new" type="text"> <fileDesc> <titleStmt> <title type="main" level="m">1. Letter of Valerian and Gallien +us</title> <editor role="editor">Joyce M. Reynolds</editor> </titleStmt> <publicationStmt> <date>2004</date> </publicationStmt> <sourceDesc default="NO"> <p><!-- to be added --></p> </sourceDesc> </fileDesc> <profileDesc> <langUsage default="NO"> <language id="eng">English</language> <language id="fre">French</language> <language id="ger">German</language> <language id="grc">Ancient Greek</language> <language id="gre">Modern Greek</language> <language id="ita">Italian</language> <language id="lat">Latin</language> <language id="spa">Spanish</language> <language id="tur">Turkish</language> </langUsage> </profileDesc> </body> </text> </TEI.2>
the perl xpath script i used is
#!/usr/bin/perl use warnings; use strict; use XML::XPath; use XML::XPath::XMLParser; my $xp = XML::XPath->new(filename => 'E:\xmlfiles\eAla001.xml'); my $nodeset = $xp->find('//@editor role'); # find all editors foreach my $node ($nodeset->get_nodelist) { print XML::XPath::XMLParser::as_string($node), "\n\n"; }
Im getting this error
:501 Protocol scheme 'e' is not supported e:/tei-epidoc.dtd Handler couldn't resolve external entity at line 2, column 40, byte 80 error in processing external entity reference at line 2, column 40, by +te 80: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE TEI.2 SYSTEM "tei-epidoc.dtd" > =======================================^ <TEI.2 lang="eng" id="eAla224"> <teiHeader status="new" type="text"> at C:/Perl/lib/XML/Parser.pm line 187
please help me out :(
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl xpath extraction
by Gulliver (Monk) on Apr 28, 2011 at 14:34 UTC |