• 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
Re: More XML stuff - reading - changing - and writing the file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More XML stuff - reading - changing - and writing the file


  • Subject: Re: More XML stuff - reading - changing - and writing the file
  • From: Steve Thompson <email@hidden>
  • Date: Thu, 10 Jun 2010 11:33:36 -0700

Wow.

Thanks for that great reply. Turned my jumbled mess into a lean, mean machine. Not to mention I understand how to use XMLLib correctly now. Thanks.

A few things for the benefit of someone that may have the same question now or in the future and come across this:

My XML looks like this:

<?xml version="1.0"?>
<session>
 <values>
  <value id="PA_MD_CUST_ANGLE">
   <string xml:space="preserve">ANGLE</string>
  </value>
  <value id="PA_MD_CUST_SCENE">
   <string xml:space="preserve">SCENE</string>
  </value>
  <value id="CUST_SIZE">
   <bigint>4036221402</bigint>
  </value>
  <value id="PA_MD_CUST_CLIPIT_ANNOTATION_REQUEST">
   <bool>true</bool>
  </value>

...and so on...

 </values>
</session>

And, I wanted to remove a number of <value>...</value> defined by value id's as: set fieldsToRemove to {"FIELD_NAME_ONE", "FIELD_NAME_TWO",...}

I ended up with:

set XMLtext to XMLOpen tempXML
set the_root to XMLRoot XMLtext
repeat with j from 1 to count of items in fieldsToRemove
set theXMLPath to "values[1]/value[@id=" & quoted form of (item i of fieldsToRemove) & "]"
XMLRemove (XMLXPath the_root with theXMLPath)
XMLSave XMLtext
end repeat
XMLClose the_root

I struggled a bit with getting the XMLXPath argument correct (quotes and such) but it works as shown.

Thanks again Emmanuel and everyone.


Steve Thompson
email@hidden



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: More XML stuff - reading - changing - and writing the file
      • From: Emmanuel LEVY <email@hidden>
References: 
 >More XML stuff - reading - changing - and writing the file (From: Steve Thompson <email@hidden>)
 >Re: More XML stuff - reading - changing - and writing the file (From: Steve Thompson <email@hidden>)
 >Re: More XML stuff - reading - changing - and writing the file (From: Steve Thompson <email@hidden>)
 >Re: More XML stuff - reading - changing - and writing the file (From: Emmanuel LEVY <email@hidden>)

  • Prev by Date: Help with script please
  • Next by Date: Re: Help with script please
  • Previous by thread: Re: More XML stuff - reading - changing - and writing the file
  • Next by thread: Re: More XML stuff - reading - changing - and writing the file
  • Index(es):
    • Date
    • Thread