mIRC Home    About    Download    Register    News    Help

Print Thread
xml retaining structure or alternative #254591 18/08/15 11:04 PM
Joined: May 2014
Posts: 35
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 35
hello, you know you can create a simple client to connect to XML-RPC wordpress to publish post for example. but I try to send data from a file with $read, does not preserve the structure of xml me and gives me error, goes like this:

Code:
<?xml version="1.0"?>
<methodCall>
<methodName>metaWeblog.newPost</methodName>
<params>
<param>
<value>
<i4>1</i4>
</value>
</param>...



  and should go like this:

Code:
<?xml version="1.0"?>
<methodCall>
  <methodName>metaWeblog.newPost</methodName>
  <params>
    <param>
      <value>
        <i4>1</i4>
      </value>
    </param>
    <param>...



you know if there's any way to fix this? Greetings

pd: server response...
Code:
<value><string>parse error. not well formed</string></value>

Last edited by Perl; 18/08/15 11:05 PM.
Re: xml retaining structure or alternative [Re: Perl] #254592 19/08/15 12:15 AM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
Use $bread instead, but whitespace shouldn't be causing that error.

Re: xml retaining structure or alternative [Re: Perl] #254599 19/08/15 10:00 AM
Joined: Jul 2006
Posts: 3,623
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,623
That might just be an example but your xml isn't well formatted indeed, is the real file well formatted? unless you pastebin both the file and the code we can't help you much.

@loki: /bread confused


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: xml retaining structure or alternative [Re: Wims] #254623 19/08/15 10:45 PM
Joined: May 2014
Posts: 35
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 35
hi, thanks for the help, try $bread and I had the same error, the client sends data socket this is the code:

Code:
alias connect {
    set %xmlinc 1
    set %xmlarchivo C:\Users\admin\Desktop\testxml.txt 
    sockopen xml $+ $rand(0,99999) domain.com 80
}

on 1:sockopen:xml*: {
    sockwrite -n $sockname POST /es/xmlrpc.php HTTP/1.1
    sockwrite -n $sockname Content-Type: text/xml
    sockwrite -n $sockname User-Agent: XML-RPC.NET
    sockwrite -n $sockname Host: domain.com
    sockwrite -n $sockname Content-Length: $len(%xmlarchivo)
    sockwrite -n $sockname Connection: Keep-Alive
    sockwrite -n $sockname $crlf
    
    while (%xmlinc <= $lines(%xmlarchivo)) {
      sockwrite -n $sockname $read(%xmlarchivo,%xmlinc)
      inc %xmlinc
    } 
}

on 1:sockread:xml*: {
  sockread %xmldatos
  echo -s %xmldatos 
}


and the server's response is the same:

Code:
HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
Content-Length: 403
Date: Wed, 19 Aug 2015 22:39:03 GMT
Accept-Ranges: bytes
Server: LiteSpeed
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>-32700</int></value>
</member>
<member>
<name>faultString</name>
<value><string>parse error. not well formed</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>



and the contents of the file is a publication xmlarchivo.txt in wordpress for XML-RPC protocol metaWeblog:


Code:
<?xml version="1.0"?>
<methodCall>
  <methodName>metaWeblog.newPost</methodName>
  <params>
    <param>
      <value>
        <i4>1</i4>
      </value>
    </param>
    <param>
      <value>
        <string>user</string>
      </value>
    </param>
    <param>
      <value>
        <string>pass</string>
      </value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>title</name>
            <value>
              <string>nuevo tituloooooooooo</string>
            </value>
          </member>
          <member>
            <name>description</name>
            <value>
              <string>&lt;iframe src="https://www.youtube.com/watch?v=v_Ci0z2rLLs" frameborder=0 width=510 height=400 scrolling=no&gt;&lt;/iframe&gt;</string>
            </value>
          </member>
          <member>
            <name>categories</name>
            <value>
              <array>
                <data>
                  <value>
                    <string>accion</string>
                  </value>
                </data>
              </array>
            </value>
          </member>
          <member>
            <name>post<name>mt_keywords</name>
            <value>
              <string>tag1,tag2</string>
            </value>
          </member>
          <member>
            <name>custom_fields</name>
            <value>
              <array>
                <data>
                  <value>
                    <struct>
                      <member>
                        <name>key</name>
                        <value>
                          <string>duration</string>
                        </value>
                      </member>
                      <member>
                        <name>value</name>
                        <value>
                          <string>1:02</string>
                        </value>
                      </member>
                    </struct>
                  </value>
                  <value>
                    <struct>
                      <member>
                        <name>key</name>
                        <value>
                          <string>image</string>
                        </value>
                      </member>
                      <member>
                        <name>value</name>
                        <value>
                          <string>http://www.images.com.jpg</string>
                        </value>
                      </member>
                    </struct>
                  </value>
                  <value>
                    <struct>
                      <member>
                        <name>key</name>
                        <value>
                          <string>ID</string>
                        </value>
                      </member>
                      <member>
                        <name>value</name>
                        <value>
                          <string />
                        </value>
                      </member>
                    </struct>
                  </value>
                  <value>
                    <struct>
                      <member>
                        <name>key</name>
                        <value>
                          <string>video</string>
                        </value>
                      </member>
                      <member>
                        <name>value</name>
                        <value>
                          <string>http://www.youtube.com/watch?v=T_2jF-_LnNg</string>
                        </value>
                      </member>
                    </struct>
                  </value>
                </data>
              </array>
            </value>
          </member>
        </struct>
      </value>
    </param>
    <param>
      <value>
        <boolean>1</boolean>
      </value>
    </param>
  </params>
</methodCall>


publish feel much, but that I think is complete and no missing data, if you can give me some help, I is not doing wrong, and no more try ... Greetings

Re: xml retaining structure or alternative [Re: Perl] #254624 19/08/15 11:29 PM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
$len(%xmlarchivo) returns the length of the filename string, not the size of the file, use $file(%xmlarchivo).size

You'll need to /bread with this method because $read() will strip the whitespace and mess up the content-length

Last edited by Loki12583; 19/08/15 11:30 PM.
Re: xml retaining structure or alternative [Re: Loki12583] #254641 21/08/15 10:38 AM
Joined: May 2014
Posts: 35
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 35
Thanks Loki12583, because tests have to do with bread, to see if I can work well, thank you both for the great help. Regards.

Re: xml retaining structure or alternative [Re: Perl] #254663 23/08/15 11:14 PM
Joined: May 2014
Posts: 35
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 35
Hi, I managed to pass binary variable data file. and I've replaced $len, use $file(%xmlarchivo).size . but I can not read the second line of the file my code is this:


Code:
alias testb {
  bread -t $qt(%xmlarchivo) 0 99999999 &tempFile
  echo -s $bvar(&tempFile,1,10000).text
}


result:

Code:
<?xml version="1.0"?>

is always line 1 of file.

and the result gives the first line of the file, but if I remove parameter "-t" in bread, me too long is a line that fails to send sockwrite to be too long. there any solution? and I not know what else to try, thanks and greetings.

Last edited by Perl; 23/08/15 11:16 PM.
Re: xml retaining structure or alternative [Re: Perl] #254664 23/08/15 11:23 PM
Joined: Jan 2004
Posts: 1,282
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,282
You send it directly with /sockwrite $sockname &tempFile

Re: xml retaining structure or alternative [Re: Loki12583] #254665 24/08/15 12:20 AM
Joined: May 2014
Posts: 35
P
Perl Offline OP
Ameglian cow
OP Offline
Ameglian cow
P
Joined: May 2014
Posts: 35
Originally Posted By: Loki12583
You send it directly with /sockwrite $sockname &tempFile


Loki12583 many thank you very much, now works well, can feel to much, but I'm new to many things and did not know how to do it, that was the solution.

Thanks wims and Loki12583, a greeting.