• 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: XMLNextSibling is there an easier way
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XMLNextSibling is there an easier way


  • Subject: Re: XMLNextSibling is there an easier way
  • From: email@hidden
  • Date: Thu, 1 May 2008 12:03:38 +0200

Title: Re: XMLNextSibling is there an easier way
At 10:43 PM -0500 4/30/08, Jim Skibbie wrote:
Then either of the two suggestions I received work (as long as I make reference to the namespace prefix in the below examples):

        set theThingYouReLookingFor to XMLGetText (XMLXPath the_root with "//fred:ROW/fred:Value[../fred:IDNoSetItemParent='6353368']")
  --  {"VARnumber"}

or
  
      set theThingYouReLookingFor to XMLGetText (XMLXPath the_root with "fred:ROW/fred:IDNoSetItemParent[. = \"6353368\"]/following-sibling::fred:Value[position()=1]")
  --  {"VARnumber"}
        
There's a lot of 'fred' to go around.

Yes, the resulting obfuscation is a high price to pay the absolute universality that namespaces allow.

Tong in cheek, they made XML, then they said "would be too simple, everyone will be able to use it, is that what we want?", so they made namespaces.

That's why XMLLib enables a "bypassing namespaces" option for XMLOpen, which should allow you to get rid of the "fred" stuff. Maybe you could give this option a try.

Finally, back to your post's original subject, you can get rid of the nextsibling if you say "search the ROW which contains an IDNoSetItemParent equal to 6353368, and return its VALUE child". Which gives:

set the_root to XMLRoot (XMLOpen theFile with bypassing namespace)
XMLXPath the_root with "ROW[IDNoSetItemParent='6353368']/Value"
or, if you just want the textual value of the node:

XMLXPath the_root with "string(ROW[IDNoSetItemParent='6353368']/Value)"
-- "VARnumber"

(and, you see, single quotes make a more legible XPath.)

Emmanuel
 _______________________________________________
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

  • Prev by Date: Re: Sending an application to the Dock?
  • Next by Date: Re: Sending an application to the Dock?
  • Previous by thread: "Opening" application Mail from the Dock
  • Next by thread: Re: XMLNextSibling is there an easier way
  • Index(es):
    • Date
    • Thread