Using the XML Classes

I’m not really new to Xojo but I a virgin with using XML.

I have to extract a field from an Adobe Lightroom Catalog (which is just a SQLite database) which contains an XMP document. Can the Xojo classes read XMP which is a little different than XML.

I have gotten the xmp data extracted and in a string field. I have looked at the examples and the book but am still somewhat confused. Following is a portion of the document which includes the beginning with ID info, some of the middle and then the section I need to get to near the bottom.

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c011 79.156380, 2014/05/21-23:38:37        ">
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
    xmlns:xmp="http://ns.adobe.com/xap/1.0/"
    xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
    xmlns:xmpRights="http://ns.adobe.com/xap/1.0/rights/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
    xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
    xmlns:exifEX="http://cipa.jp/exif/1.0/"
    xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"
    xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/"
    xmlns:crss="http://ns.adobe.com/camera-raw-saved-settings/1.0/"
    xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
    xmlns:exif="http://ns.adobe.com/exif/1.0/"
    xmlns:dng="http://ns.adobe.com/dng/1.0/"
   photoshop:DateCreated="2004-01-25T11:24:12Z"
   .
   .
   .
   xmp:Rating="5"
   xmp:Label="Raw/DNG"
   xmp:CreatorTool="Adobe Photoshop Lightroom 6.2.1 (Macintosh)"
   aux:SerialNumber="113148"
   aux:LensInfo="70/1 200/1 0/0 0/0"
   aux:Lens="70.0-200.0 mm"
   aux:ImageNumber="244"
   .
   .
   .
      dng:HasFastLoadData="False"
   dng:OriginalRawFileName="35CV0191.TIF"
   dng:HasEmbeddedOriginalRawFile="False">
   <xmpRights:UsageTerms>
    <rdf:Alt>
     <rdf:li xml:lang="x-default">All Rights Reserved</rdf:li>
    </rdf:Alt>
   </xmpRights:UsageTerms>
   <dc:creator>
    <rdf:Seq>
     <rdf:li>William (Bill) Plunkett</rdf:li>
    </rdf:Seq>
   </dc:creator>
   ++++++++++++++++THIS IS THE SECTION I NEED TO EXTRACT++++++++++++++
   <dc:title>
    <rdf:Alt>
     <rdf:li xml:lang="x-default">Firehole Falls, Yellowstone National Park</rdf:li>
    </rdf:Alt>
   </dc:title>
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
   <dc:rights>
    <rdf:Alt>
     <rdf:li xml:lang="x-default">© 2016 William Plunkett</rdf:li>
    </rdf:Alt>
   </dc:rights>

Could someone kindly give me a little guidance on how to extract the image title?

Thanks so much in advance.

Hi,

I don’t know much about XMP, but I know Christian has XMP in MBS Plugins.

Marius

You can loop over all XML nodes and look of the text inside a dc:title tag.
But that only finds this one.

Or you use the XMP plugin to query title tag:
http://www.monkeybreadsoftware.de/xojo/plugin-xmp.shtml

Christian, went to your site and am not clear. Can I download this plug-in only for free or must I purchase the complete license to use the xmp plug-in?

thanks,

I’d use an XQL query to get it but …
https://forum.xojo.com/9885-xql-node-that-starts-with

Just search for “XQL” in the forums & you’ll find LOTs of posts about using it

You can download the plugin and try it.

Later you can check the license.

While XMP is not on the price list, I could sell a separate license. But maybe better get Complete set?

I believe XML causes insanity. ;-))

Recently I have been working on converting a massive XML file with many nodes (right term ??) that are many levels deep into a SQL database. I will need to do this several times per week to refresh the data.

The thing that made it work for me was recursion. I found a simple example here:
https://forum.xojo.com/3169-trying-to-parse-xml

I used the basic structure of this example and parse my XML into a text box. This makes experimenting with the logic fairly easy and quick. The basic parsing only has a few dozen lines of code that mostly are used to format the output into the text box to make it readable and in some sort of hierarchy that is understandable.

Say x as the xmlDocument object of you XMP source

[code]//Define the used namespace (they are declared in the first node, not at document element so you have to explicit them
dim ns() as String
ns.Append “rdf”
ns.Append “http://www.w3.org/1999/02/22-rdf-syntax-ns#
ns.append “dc”
ns.append “http://purl.org/dc/elements/1.1/

//Query the document
dim xq as XmlNodeList
xq=x.DocumentElement.Xql(“rdf:RDF/rdf:Description/dc:title/rdf:Alt/rdf:li/text()”, ns)
if xq.Length>0 Then
theTitle=xq.item(0).value
end if[/code]