ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Re: XMP Parsing Question
by Michael Nachbaur other posts by this author
Sep 22 2005 1:29PM messages near this date
view in the new Beta List Site
XMP Parsing Question | Re: XMP Parsing Question
& XSLT my $parser = new XML::LibXML();
my $doc = $parser-> parse_string($xmp);
# or:
# my $doc = $parser-> parse_file($xmp_filename);
my $rootNode = $doc-> documentElement();
my $image = $rootNode-> findvalue('//xapgimg:image');

Or if you want to be more specific, you can use the following for the 
last line:
my $image = 
$rootNode-> findvalue('/x:xmpmeta/rdf:rdf//xap:thumbnails//xapgimg:image');

This code assumes that only one thumbnail exists.  However, it should 
suffice.

The above code illustrates using XPath to query the contents of the XML 
file.  You may want to look into XPath more, because it is a very 
powerful way of interacting with XML documents, and would let you get 
more out of this document easily if you need to.

Christopher Pryce wrote:
>  I'm not terribly good with XML yet, but I'm learning.
>  
>  How would I go about extracting the value of the <xampimg:image> tag in 
>  the following XML fragment, using XML::LibXML ?
>  
>  Thanks very much.
>  
>  -- 
>  
>  
>  <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP toolkit 2.9.1-13, 
>  framework 1.6">
>      <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
>  xmlns:ix="http://ns.adobe.com/iX/1.0/">
>          <rdf:description xmlns:pdf="http://ns.adobe.com/pdf/1.3/" 
>  rdf:about="uuid:93ab74ca-923b-11d9-b281-0003934be352" 
>  pdf:producer="Adobe PDF library 6.66" />
>          <rdf:description 
>  xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" 
>  rdf:about="uuid:93ab74ca-923b-11d9-b281-0003934be352" 
>  photoshop:datecreated="2005-03-11T00:00:00Z" 
>  photoshop:city="Minneapolis" photoshop:state="MN" 
>  photoshop:country="Hennepin" photoshop:credit="SRF Consulting Group, 
>  Inc." />
>          <rdf:description xmlns:xap="http://ns.adobe.com/xap/1.0/" 
>  xmlns:xapgimg="http://ns.adobe.com/xap/1.0/g/img/" 
>  rdf:about="uuid:93ab74ca-923b-11d9-b281-0003934be352" 
>  xap:createdate="2005-03-11T08:14:14-06:00" 
>  xap:modifydate="2005-03-11T08:40:56-06:00" xap:creatortool="Illustrator" 
>  xap:metadatadate="2005-03-11T08:40:56-06:00">
>              <xap:thumbnails>
>                  <rdf:alt>
>                      <rdf:li rdf:parsetype="Resource">
>                          <xapgimg:format>
>                              JPEG
>                          </xapgimg:format>
>                          <xapgimg:width>
>                              244
>                          </xapgimg:width>
>                          <xapgimg:height>
>                              256
>                          </xapgimg:height>
>                          <xapgimg:image>
>                              #### Some Binary Data that I want. ########
>                          </xapgimg:image>
>                      </rdf:li>
>                  </rdf:alt>
>              </xap:thumbnails>
>          </rdf:description>
>          <rdf:description xmlns:xapmm="http://ns.adobe.com/xap/1.0/mm/" 
>  rdf:about="uuid:93ab74ca-923b-11d9-b281-0003934be352" 
>  xapmm:documentid="uuid:84758202-923b-11d9-b281-0003934be352" />
>          <rdf:description xmlns:dc="http://purl.org/dc/elements/1.1/" 
>  rdf:about="uuid:93ab74ca-923b-11d9-b281-0003934be352" 
>  dc:format="application/vnd.adobe.illustrator">
>              <dc:creator>
>                  <rdf:seq>
>                      <rdf:li>
>                          Christopher Pryce
>                      </rdf:li>
>                  </rdf:seq>
>              </dc:creator>
>          </rdf:description>
>      </rdf:rdf>
>  </x:xmpmeta>
>  
>  _______________________________________________
>  Perl-XML mailing list
>  Perl-XML@[...].com
>  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Christopher Pryce
Michael Nachbaur
Christopher Pryce
Bruce Miller
Michael Nachbaur

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved