Reading XML data from .pages file

Hi All!


I've been trying to get a script up and running, but frankly I'm lost. The script should read the date, lesson no, and name fields from a .pages file and then use that information to send an e-mail.


What I'm having a problem with is reading the data from the .pages file and I don't know what the best way to do it is because I'm still a novice at this.


So there are two ways I can think of:


1. Read directly from the Pages document when it is open. The problem with this is that it's a Pages template and it contains tables. Perhaps the easiest thing would be just to select certain cells directly from pages, but I have no idea how they're labeled or how to access them so I came up with a second idea. If you happen to know how to do this, I would greatly appreciate it.


2. Pages documents can be unzipped and one of the files is an xml file with a lot of tags and the data I need. I found the following post that talks about how to parse XML via an XSL stylesheet. After going through some tutorials, I got stuck because the xml itself in the Pages file is just a mess to me and I'm confused about which node to choose. In other xml docs you can see a clear, nicely laid out tabbed structure so you can at least figure out the path to the node you want. I stumbled across a nice script for TextWrangler which cleans up XML, but it just barks at the Pages file.


3. On top of that, I will need to use the name field and match that with an Address Book e-mail address. Should I change the template and make it into an address book field?


Thanks in advance,


Paul

Posted on Mar 23, 2012 12:19 PM

Reply
17 replies

Mar 30, 2012 5:31 AM in response to rccharles

Hi rccharles,


Thanks for your input. The colon is used to define namespaces in XML. There's a nice tutorial on w3schools you might want to take a look at.


Parsing Pages' xml file is another option, and the more I read about AppleScript, the more I see that it wouldn't be too difficult. But the problem's been solved and I'm looking forward to replacing the current template I've made with something that will produce XML output. I want it to store the lesson data in a database and the reviews will be in HTML format. The PDFs are a bit too big IMHO, but nice to print.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Reading XML data from .pages file

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.