• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Help parsing XML file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help parsing XML file


  • Subject: Help parsing XML file
  • From: Jim Skibbie <email@hidden>
  • Date: Fri, 07 Mar 2008 12:34:52 -0600
  • Thread-topic: Help parsing XML file

Title: Help parsing XML file
I have an XML file that will return results like this:

<?xml version="1.0" encoding="UTF-8"?>
<FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult">
    <ERRORCODE>0</ERRORCODE>
    <DATABASE>ColorTable</DATABASE>
    <LAYOUT>XMLLayout</LAYOUT>
    <ROW MODID="4" RECORDID="12915141">
        <ValueColor01>Process</ValueColor01>
        <ValueColor02>Process</ValueColor02>
        <ValueColor03>Process</ValueColor03>
        <ValueColor04>Process</ValueColor04>
    </ROW>
    <ROW MODID="6" RECORDID="12915142">
        <ValueColor01>150</ValueColor01>
        <ValueColor02>150</ValueColor02>
        <ValueColor03>150</ValueColor03>
        <ValueColor04>150</ValueColor04>
    </ROW>
    <ROW MODID="2" RECORDID="12915143">
        <ValueColor01>Yellow</ValueColor01>
        <ValueColor02>Magenta</ValueColor02>
        <ValueColor03>Cyan</ValueColor03>
        <ValueColor04>Black</ValueColor04>
    </ROW>
    <ROW>
    ...etc...
    </ROW>
</FMPDSORESULT>


I’m trying to use an Applescript to parse the file using the XMLLib osax but I’m not having any luck because I don’t think I grasp the Xpath concept or I’m missing something.

What I need to do is place the text of the tag inside a variable for each “ValueColor0x” tag, so that the result would be something like:

ColorInfo01 = {“Process”, “150” , “Yellow”}
ColorInfo02 = {“Process”, “150” , “Magenta”}
ColorInfo03 = {“Process”, “150” , “Cyan”}
ColorInfo03 = {“Process”, “150” , “Black”}

I thought I could use the XMLXPath function of the XMLLib osax to point to all the nodes in the root doc with “ROW/ValueColor01” and get back a list of the three nodes and then get their text values, but that doesn’t seem to work.

Does anyone have experience with XMLLib osax that could point me in the right direction? Or is there some other osax that does better with parsing XML?

Thanks.
Jim
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Help parsing XML file
      • From: Ed Stockly <email@hidden>
    • Re: Help parsing XML file
      • From: Jim Skibbie <email@hidden>
  • Prev by Date: Re: Do Shell script with unix sub command and CocoaDialog
  • Next by Date: Re: Help parsing XML file
  • Previous by thread: Re: Plist Problem (LNS Property List Tools)
  • Next by thread: Re: Help parsing XML file
  • Index(es):
    • Date
    • Thread