hi guys :wink:
i need your help for my mirc script
i try to create some xml parser for mirc HTTP socket script
you can find the xml file sample here
http://api.erepublik.com/v2/feeds/citizen_by_name/xml/ipewannasay
there are so many tag named
I had a problem to access the tag that has text: [b]Allies of Indonesia
[/b]
then i have made a script that made a temporary root address
can you help me simplify that code :D
or maybe you have some other method to parse xml in mirc language please share here
on *:text:.link*:#: {
if ( $me != %botnick ) halt
else {
var %idtlp $right($ticks,8)
var %sntlp socktlp. [ $+ [ %idtlp ] ]
set %chan. [ $+ [ %sntlp ] ] $chan
set %nick. [ $+ [ %sntlp ] ] $nick
if ( $2 == $null ) syntax $1 %chan. [ $+ [ %sntlp ] ]
elseif ( $2 != $null ) {
sockclose %sntlp
var %lc. [ $+ [ %sntlp ] ] $replace( $2- ,$chr(32), $chr(37) $+ 20 )
set %ln. [ $+ [ %sntlp ] ] $( $+ /v2/feeds/citizen_by_name/xml/ $+ %lc. [ $+ [ %sntlp ] ] )
notice %nick. [ $+ [ %sntlp ] ] Processing Request...
sockopen %sntlp api.erepublik.com 80
}
else syntax $1 %chan. [ $+ [ %sntlp ] ]
}
}
on *:SOCKOPEN:socktlp*: {
sockwrite -nt $sockname GET %ln. [ $+ [ $sockname ] ] HTTP/1.1
unset %ln. [ $+ [ $sockname ] ]
sockwrite -nt $sockname Host: api.erepublik.com
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:socktlp*: {
var %sntlp $sockname
if ($sockerr) {
msg %chan. [ $+ [ %sntlp ] ] Socket Error: %sntlp $+ . Error code: $sockerr Please inform $me of this error message.
unset %chan. [ $+ [ %sntlp ] ] %nick. [ $+ [ %sntlp ] ]
sockclose %sntlp
}
else {
set %rd. [ $+ [ %sntlp ] ]
var %rdv %rd. [ $+ [ %sntlp ] ]
sockread %rdv
if ( $nohtml( %rdv ) == $null ) {
if ( <citizen> isin %rdv ) set %i. [ $+ [ %sntlp ] ] 0
if ( / !isin %rdv ) {
inc %i. [ $+ [ %sntlp ] ]
var %ii %i. [ $+ [ %sntlp ] ]
set %th [ $+ [ %ii ] $+ . $+ [ %sntlp ] ] %rdv
}
var %iii 0
while ( %iii <= %i. [ $+ [ %sntlp ] ] ) {
inc %iii
set %echothread %echothread %th [ $+ [ %iii ] $+ . $+ [ %sntlp ] ]
}
if ( %echothread != $null ) echo 4 -a %echothread
unset %echothread
}
elseif ( $nohtml( %rdv ) != $null ) {
echo 3 -a %i. [ $+ [ %sntlp ] ] %rdv
if ( <message> isin %rdv ) {
set %error. [ $+ [ %sntlp ] ] $nohtml( %rdv )
msg %chan. [ $+ [ %sntlp ] ] ERROR: %error. [ $+ [ %sntlp ] ]
unset %chan. [ $+ [ %sntlp ] ] %nick. [ $+ [ %sntlp ] ] %rd. [ $+ [ %sntlp ] ] %error. [ $+ [ %sntlp ] ] %i. [ $+ [ %sntlp ] ]
sockclose %sntlp
halt
}
}
if ( $nohtml( %rdv ) == $null ) {
if ( / isin %rdv ) {
if ( ></ !isin %rdv ) {
if ( </ isin %rdv ) {
var %ii %i. [ $+ [ %sntlp ] ]
unset %th [ $+ [ %ii ] $+ . $+ [ %sntlp ] ]
dec %i. [ $+ [ %sntlp ] ]
}
elseif ( /> isin %rdv ) echo 4 -a EMPTY THREAD %rdv
}
else echo 4 -a EMPTY THREAD %rdv
}
if ( </citizen> isin %rdv ) {
echo 4 -a DOR :|
unset %username. [ $+ [ %sntlp ] ] %profile. [ $+ [ %sntlp ] ] %donate. [ $+ [ %sntlp ] ]
unset %chan. [ $+ [ %sntlp ] ] %nick. [ $+ [ %sntlp ] ] %i. [ $+ [ %sntlp ] ] %rd. [ $+ [ %sntlp ] ] %th1. [ $+ [ %sntlp ] ] %th2. [ $+ [ %sntlp ] ] %th3. [ $+ [ %sntlp ] ] %th4. [ $+ [ %sntlp ] ]
sockclose $sockname
}
}
}
}
wrong place to ask for help. You should have posted this in the forum under mIRC Snippet Requests