XML Parser
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.