Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > help with some xml automation ?

help with some xml automation ?
Thread Tools
Senior User
Join Date: Jul 2001
Status: Offline
Reply With Quote
Jun 30, 2005, 04:43 PM
 
I have this bit of xml
<IMAGE>
<NAME>image1.jpg</NAME>
<CAPTION>Image 1</CAPTION>
</IMAGE>

I want to swap out the image1.jpg and Image 1 to ++ increasing strings of image2.jpg Image 2 like
<IMAGE>
<NAME>image1.jpg</NAME>
<CAPTION>Image 1</CAPTION>
</IMAGE>
<IMAGE>
<NAME>image2.jpg</NAME>
<CAPTION>Image 2</CAPTION>
</IMAGE>

I have a LONG list I need to make and just wonder if there is a tool that can do this.

please and thankyou
     
Posting Junkie
Join Date: Jun 2001
Location: Washington DC
Status: Offline
Reply With Quote
Jun 30, 2005, 05:10 PM
 
I don't know why I decided to do this in PHP, but it'll be basically the same in pretty much any programming/scripting language:

Code:
$numImages = x; #where x is however many images you have for ($i = 1; $i <= $numImages; $i++) { echo "<IMAGE>\n"; echo "<NAME>image$i.jpg</NAME>\n"; echo "<CAPTION>Image $i</CAPTION>\n"; echo "</IMAGE>\n"; }
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Jun 30, 2005, 05:13 PM
 
[php]
to generateImageSnippet(imageNumber)

set xmlFragment to "<IMAGE>
<NAME>image" & imageNumber & ".jpg</NAME>
<CAPTION>Image " & imageNumber & "</CAPTION>
</IMAGE>
"

return xmlFragment
end generateImageSnippet



on run
set xmlList to ""
set numberIndex to 1
repeat while numberIndex is less than or equal to 100
set xmlList to xmlList & my generateImageSnippet(numberIndex)
set numberIndex to numberIndex + 1
end repeat
log xmlList
end run
[/php]
     
loren s  (op)
Senior User
Join Date: Jul 2001
Status: Offline
Reply With Quote
Jul 5, 2005, 10:45 AM
 
Neat thank you, I will have to read more into it but thank you
Sorry about the late reply, have been really busy,, I hope this works
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:21 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2