• AVR Freaks

Hot!XML Parse Error

Author
Davide33
New Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2019/03/29 06:04:47
  • Location: 0
  • Status: offline
2019/04/16 01:49:17 (permalink)
0

XML Parse Error

Hi guys,
 
recently i'm trying to write some .xml documents to retrive the status of specifics variables using TCP_HTTP_Print() functions.
So far so good, but yesterday i discovered a parse error (retrived from a status xml document) that say this:
 
"This page contains the following errors: parserror"
 
This is the source code of xml page:
 
<response>
<sett_hello>~setHello~</sett_hello>
</response>

 
Then when the xml is called by the Ajax call, this page is returned (with the parse error):
 
<response>
<sett_hello>~setHello~</sett_h0llo>
</response>

 
As you can see, the end tag "</sett_h0llo>" contains a mysterious "0"...
 
I have tried a lot of fix but the "bug" disappears only if i delete the xml document.
Anyone can help me?
post edited by Davide33 - 2019/04/16 02:03:57
#1

9 Replies Related Threads

    andersm
    Super Member
    • Total Posts : 2581
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: online
    Re: XML Parse Error 2019/04/16 03:23:03 (permalink)
    0
    The most anyone can say with the little information you provided is "fix the thing that is messing up your tags".
    #2
    rodims
    Super Member
    • Total Posts : 1478
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: XML Parse Error 2019/04/16 03:30:44 (permalink)
    0
    How does this question fit into the Microchip cosmos ?
     
    I have tried a lot of fix but the "bug" disappears only if i delete the xml document.

     
    What do you consider to be the bug, and what do you want to fix ? Obviously the XML document is damaged, you need to fix the origin of the problem, not the symptom. 
     
    What is the context of TCP_HTTP_Print() ? Which hardware ? Which system ? Which library ? 
    And you did not mention how often / and in which context TCP_HTTP_Print() fails.  It always produces errors ? (which I doubt).   If this happened once and never again, you cannot debug it.
     
    It sounds that you are reading the XML document on the PC, but where does it come from ?
    Just from the symptom I would suspect some problem with the XML writer, or your media, e.g. flash memory
    #3
    Davide33
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2019/03/29 06:04:47
    • Location: 0
    • Status: offline
    Re: XML Parse Error 2019/04/16 06:13:05 (permalink)
    0
    Thanks for the replies guys.
     
    The most anyone can say with the little information you provided is [...]

     
    sorry for that, now i provide you more informations:
     
    My board: PIC32MZ,
    IDE: MPLAB X v5.15,
    Using also Harmony Configurator v 2.0.5.2
     
    What i need to do is a web server (using TCPIP Stack in Harmony) that provide responses calling some xml files via browser, and in these responses i need to print some system variables.
     
    Currently i have 4 xml files that print values from the system, the 2nd one is the file that return "parse error" when called by the browser javascript Ajax call.
    The other 3 files works pretty good, and the values are retrived correctly.
     
    I have checked the xml code and the tags are all correct.
     
    I provide an example of what i'm doing:
    (The print functions are generated using Microchip MPFS Generator)
     
    C Source File:
    void TCPIP_HTTP_Print_firstSysVar(HTTP_CONN_HANDLE connHandle)
    {
        uint8_t AN0String[8];

        sprintf((char *)AN0String, "%d", firstSysVar);
        TCPIP_TCP_StringPut(TCPIP_HTTP_CurrentConnectionSocketGet(connHandle), AN0String);
    }

     
    XML File:
    <response>
    <firstFile_firstSysVar>~firstSysVar~</firstFile_firstSysVar>
    </response>

     
    JS Code (Using Jquery):
    function getFirstSysVar()
     
    {
        $.ajax({url: "firstFile.xml",
            type: "GET",
            success: function(response){

                  // Here i handle the response
                  handle_response(response);
            }
        });
    }

     
    But the result (only for the 2nd file) is a parse error.
     
    post edited by Davide33 - 2019/04/16 06:26:58
    #4
    Jim Nickerson
    User 452
    • Total Posts : 5892
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: XML Parse Error 2019/04/16 07:19:18 (permalink)
    0
    Have you tried changing the tag name or the dynamic variable name ? Maybe it is confusing the system,
    #5
    Davide33
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2019/03/29 06:04:47
    • Location: 0
    • Status: offline
    Re: XML Parse Error 2019/04/16 08:02:22 (permalink)
    0
    Thanks for the reply!
     
    Have you tried changing the tag name or the dynamic variable name ? Maybe it is confusing the system,

     
    i have tried to change the dynamic var name and the tag name, the result is changed but there is the same problem: The mysterious "0" is always in the tag but has changed the position.
    post edited by Davide33 - 2019/04/16 08:06:21
    #6
    Davide33
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2019/03/29 06:04:47
    • Location: 0
    • Status: offline
    Re: XML Parse Error 2019/04/17 00:49:39 (permalink)
    0
    Anyone have others ideas?
    #7
    rodims
    Super Member
    • Total Posts : 1478
    • Reward points : 0
    • Joined: 2009/02/10 11:08:59
    • Location: 51.9627, 7.6262
    • Status: offline
    Re: XML Parse Error 2019/04/17 04:55:16 (permalink)
    0
    The mysterious "0" is always in the tag but has changed the position.

     
    Since this is obviously not a feature but a bug, you likely have to debug it yourself. I don't think it is possible to guess or assist remotely, which software bug or hardware problem is causing this strange effect.
     
    I assume you understand that you must "catch" the piece of code (or faulty hardware) in the act of injecting this '0' character into your data. Since this is difficult, I would first try to identify places in the data workflow where the data is still ok, and afterwards where it is wrong. You then try to narrow that more and more until you either find the exact location or until you might guess what could be wrong.
     
    Also have an eye on interrupts, which means non-sequential program flow.
    post edited by rodims - 2019/04/17 05:16:25
    #8
    Davide33
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2019/03/29 06:04:47
    • Location: 0
    • Status: offline
    Re: XML Parse Error 2019/04/18 02:50:27 (permalink)
    0
    Thanks for the reply.
     
    I have found something strange.. The mysterious "0" (found in the 2nd xml file) is a variables returned by HTTP_Print() function of the 3rd xml file...
    The 3rd xml file seems to have somehow conflict with the 2nd one.
    So i have checked:
     
     - 2nd and 3rd xml file tag and '~' symbols, but everything is ok.
     - HTTP_Print() functions of both files, (for find eventual pointer overflow), but also in this case is everything ok.
     
    If i delete the 3rd file, the '0' in the 2nd one disappear.
    It could be said that the problem could be the 3rd file, but i don't think so, because is everything correct in the file.
     
    So, in the light of these new discoveries, did anyone have any ideas?
    Also, anyone knows the C source file name that handles the xml responses?
     
    Thanks very much for the support!
     
    #9
    Davide33
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2019/03/29 06:04:47
    • Location: 0
    • Status: offline
    Re: XML Parse Error 2019/04/23 01:06:03 (permalink)
    0
    Anyone that have used the MPFS Generator method to build a web server has the same issues?
    #10
    Jump to:
    © 2019 APG vNext Commercial Version 4.5