Results 1 to 2 of 2

Thread: XML verification issue

  1. #1
    Join Date
    Feb 2009
    Posts
    16
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default XML verification issue

    Hi,
    I am working in a socket application where I am sending the data to the server in xml form and receiving reesponse for it in an xml format. The problem is that when I am trying to parse the message I am getting the error that it cannot parse the xml.
    I am using the API
    QDomDocument setContent(byteArray);
    in the byteArray there is a message in xml format from the server. When I debugged the API I found that the error was because of the comment format in the server response.
    The server response was
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <!--- TCP probe server response v0.121 --->
    3. <probeResponse version="1.0" xmlns="https://www.xxxx.com/schemas/probe/v1_0">
    4. <params>
    5. <period>45</period>
    6. <next>90</next>
    7. <dec>0.71</dec>
    8. <valid>604800</valid>
    9. <count>10</count>
    10. </params>
    11. <detect>
    12. <xaddress>0x0a24654e</xaddress>
    13. <xport>0x068c</xport>
    14. </detect>
    15. <timestamp>44675436</timestamp>
    16. <nonce>JwMFecnLFUz/REJ8HuQE45943</nonce>
    17. <signature method="HMAC-SHA1">ZajDI9xJLFfP3B8UFSVCmk9oyLY=</signature>
    18. </probeResponse>
    To copy to clipboard, switch view to plain text mode 
    Now the comment understood by QDomComment is in the form of
    <!-- XXXXX -->
    Since the server response is having the comment as <!--- XXXX --->
    an extra "-" so it is giving error there. When I try to write the response in file and manually remove the "-" from comment and then try to use setContent() it works like charm.
    Please help me is there any way I can define the rule to accept such comment as valid comment because the server implementation cant be changed I have to have some kind of work around to make this accept as valid xml message.

    Regards,
    Yogesh

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: XML verification issue

    Well, the trolls - or better nokias(?) - have something against tree dashes. Have a look at the QDomCommentPrivate::save() implementation:
    Qt Code:
    1. if (value.endsWith(QLatin1Char('-')))
    2. s << ' '; // Ensures that XML comment doesn't end with --->
    To copy to clipboard, switch view to plain text mode 

    So the best would be as you self have written:
    Qt Code:
    1. byteArray.replace("<!---", "<!--").replace("--->", "-->")
    To copy to clipboard, switch view to plain text mode 

    Lykurg

    P.s.: I am not sure if three dashes are valid XML even if it is only said that comments starts with "<!--" and ends with "-->"...

Similar Threads

  1. Replies: 1
    Last Post: 28th October 2008, 16:29
  2. qt4.4 pc specs requirements or qt3 support issue?
    By triperzonak in forum Installation and Deployment
    Replies: 0
    Last Post: 9th August 2008, 02:40
  3. QTableView focus issue
    By gemidjy in forum Qt Programming
    Replies: 4
    Last Post: 19th February 2008, 15:51
  4. qt3 to qt4 - uic issue
    By hvengel in forum Qt Programming
    Replies: 10
    Last Post: 4th March 2007, 02:59
  5. Replies: 5
    Last Post: 22nd September 2006, 08:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.