• 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
XML Parser
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

XML Parser


  • Subject: XML Parser
  • From: Marcus Rodrigues <email@hidden>
  • Date: Mon, 15 Sep 2003 14:40:42 -0300

This is a xml parser.

It tells me that it can't get the lenght of 77, then I run it again it
can't get the lenght of 78, again and it is 79....


Here is the code:

on tagParse(thisText, openTag, closeTag)
set new_text to ""
set strlen to the length of thisText
set taglen to (the length of openTag) - 1
set closeTagLen to (the length of closeTag) - 1
set stridx to 1
repeat until (stridx + taglen) is greater than strlen
set thisString to the contents of characters stridx through (stridx +
taglen) of thisText as text
log thisString
if thisString is openTag then
set firstChar to stridx + taglen + 1
repeat until (stridx + closeTagLen) is greater than strlen
set thisString to the contents of characters stridx through (stridx
+ closeTagLen) of thisText as text
log thisString
if thisString is closeTag then
return the contents of characters firstChar through (stridx - 1)
of thisText as text
end if
set stridx to stridx + 1
end repeat
end if
set stridx to stridx + 1
end repeat
return "Error:: tag " & openTag & " not found."
end tagParse
set fileToParse to ((path to the desktop as text) & "teste.xml") as
alias
set theFile to open for access fileToParse
read theFile as Unicode text
tagParse(theFile, "", "")


Here is the xml:


<?xml version="1.0"?>
<trabalho>
<numero>00001</numero>
<status>pronto</status>
</trabalho>


Thx for any help ;-D


o#? Marcus Rodrigues o#?
iBook 600 - Combo - Jaguar
CC4nsul do Brasil Apple Clube - Caxias do Sul
Moderador BAC-Macusers
ichat: marcusrodrigues
mailto:email@hidden
http://homepage.mac.com/marcusrodrigues
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Finding and deleting specific extensions.
  • Next by Date: Re: Finding and deleting specific extensions.
  • Previous by thread: August 2003 gcc Updater available
  • Next by thread: XML Parser
  • Index(es):
    • Date
    • Thread