PtokaX forum

Development Section => Your Developing Problems => Topic started by: Herodes on 04 September, 2004, 15:54:48

Title: some xmltag problems ..
Post by: Herodes on 04 September, 2004, 15:54:48
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..">(.*)")
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..">(.*)(.*)")
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
Title:
Post by: NotRabidWombat on 04 September, 2004, 16:21:21
http://board.univ-angers.fr/thread.php?threadid=2385&boardid=15

-NotRabidWombat
Title:
Post by: Herodes on 04 September, 2004, 17:45:31
I played so much with it that I forgot its virtues ...
thanks NotRambitWombat ..