Say I have this xml layout ...
How can I get the respective contents of the two '
' tags ..?
hahahaha
lalalala
hihhihihi
lililili
I am using this atm .. .
* str is the file in which the above xml is lying streamed in the script in a string...
tag =gsub(gsub(str, "\r\n", ""), "\t", "") --- removing the line breaks and the tabs ...
--- hahahahalalalalahihhihihilililili
if strsub(tag ,1,1) == "<" then
s,e,tagname = strfind(tag, "<([^>]*)")
print(tagname)
--- output : ALevel
s,e,internal = strfind(tag, "<"..tagname..">(.*)"..tagname..">")
print(internal.." this is inside the "..tagname)
--- output : hahahahalalalalahihhihihilililili this is inside the ALevel
s,e,inttag = strfind(internal, "<([^>]*)")
s,e,intcontents,resttag = strfind(internal, "<"..inttag..">(.*)"..inttag..">(.*)")
if resttag == "" then
resttag = "nil"
end
print("the tag "..inttag.." has "..intcontents.." and the remaining string is "..resttag)
--- output : the tag Second has hahahahalalalala
hihhihihilililili and the remaining string is nil
end
http://board.univ-angers.fr/thread.php?threadid=2385&boardid=15
-NotRabidWombat
I played so much with it that I forgot its virtues ...
thanks NotRambitWombat ..