XML Parser
XML Parser
- Subject: XML Parser
- From: Marcus Rodrigues <email@hidden>
- Date: Mon, 15 Sep 2003 15:24:13 -0300
While waiting for the answer, since my messages sometimes take 5 hours
to get to the list, I solved my problem by doing this:
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
set oConteudo to read theFile
oConteudo
tagParse(oConteudo, "<numero>", "</numero>")
Don't know if it is the best way, but it worked ;-)
Thx anyway =-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.