parsing RegisteredUsers.xml
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

parsing RegisteredUsers.xml

Started by Jemte, 03 May, 2005, 01:38:50

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jemte

I am trying to read through the registered user list so I can get an access list available for viewing.

_, _, tag = string.find(sLine, "(<.*>).*")

i thought the function only replied back with the result that was within the ()s but when i print out the value of 'tag' it shows the entire line 'Jemte' ive tried using '%S+' instead of '.*' but then the tag is 'nil'.

any suggestions/help would be appreciated.

Jemte

ok i found out that the <(.*)> reads from the beginning of the line til the end

Jemte returns 'Nick>Jemte
i tried "<(%S+)>(%w+)<(%S+)>" for the pattern but its not working...ill keep trying tho

bastya_elvtars

%b<>(.+)%b<>

means: anything surrounded by 2 thingies that are < and >

More precise would be to assign the variable name as well.

Like:
local _,_,varname,value=string.find(line,"<(.+)>(.+)%b<>")
-- and then:
table[varname]=value
Everything could have been anything else and it would have just as much meaning.

Herodes

#3
its far more better to use frmHub:GetRegisteredUsers() ..

but if you are trying to parse an xml you need to scan the string( contents of xml file ) progressively rather than pMatched..

str = [[

	Smth
	SmthElse
	
		SmMore
		SmMore
	
]]

you need to get the first tag..
s,e, sTag, sRest = string.find( str, "<([^>]+)>(.*)" )
then you need to get the contents of that tag..
s,e, sContents, sTmp = string.find( sRest, "(.-)(.-)" )
This is the main principle to parse the xml.. Carrying on from here you'll need to create a function with a while-loop to parse the sContents and the sTmp, putting the [sTag]= sContents inside a table.

That all has been done for you .. Look in the how to section There is a function I played with for a while ..

Btw:
as far as pattern matching is concerned '-' means not greedy in the results.. while '*' means greedy..
Example:
str = "12"
string.find ( str, "<(.*)>" )
-- this will result in "one>12" ) 
-- this will result in "one"
I hope its clear ;)

SMF spam blocked by CleanTalk