Re: XML_ERROR_JUNK_AFTER_DOC_ELEMENT - How to resolve
"Terry Ebaugh" <[email protected]>
| Newsgroups | gmane.text.xml.expat.general |
|---|---|
| Message-ID | <001201c6dbab$e4680270$6a01a8c0@terry> |
Nick pinpointed my problem. I didn't have any trouble parsing the files individually it only happened when I tried to pipe multiple documents to the parser via stdin. So now I'll either set up a filter or ignore the error message and be clever. Thanks for the help! Terry ------------------------------------------------- Date: Monday, Sep 18th,2006 C:\pet C:\pet\cat C:\pet\cat\ignore\human _____ From: Mukesh S [mailto:[email protected]] Sent: Tuesday, September 19, 2006 1:08 AM To: Terry Ebaugh; [email protected] Subject: RE: [Expat-discuss] XML_ERROR_JUNK_AFTER_DOC_ELEMENT - How to resolve Hi, Have you tried with individual files likes instead of reading all the files, I suggest you to go for baby steps. Like Step1 ) read the first xml file, and close it ,and immediate within you function open another file,that make sense. Step2) the next will be yours, check for the proper tag, if you are sure that all the xml files you have same format expect the data is different then it will works. My Small web-page: http://www.geocities.com/muki_champs Regards, Mukesh Srivastav, Sr.Software Engineer. India, Bangalore. +91-9980142921 (M) -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Terry Ebaugh Sent: Tuesday, September 19, 2006 4:15 AM To: [email protected] Subject: [Expat-discuss] XML_ERROR_JUNK_AFTER_DOC_ELEMENT - How to resolve Hi, I've just started working with expat. I have xml files that are gzipped. I gzcat them and pipe them to my parser. I am getting the XML_ERROR_JUNK_AFTER_DOC_ELEMENT error message and I'm unsure how to resolve. I was under the impression that it is caused by extracter character after a document root close tag. I tried stripping the chars after that close tag but that doesnt seem to work. Is this caused by a new document starting immediately after the first one has finished? Does anyone have any suggestions? Here is the error message and what was in the buffer: Parse error:file:1:row:4:column:0:reason:junk after document element BUFFER = nter></usage></dataSet></metrics> <?xml version='1.0' encoding='UTF-8'?> <metrics version="3.0" cr My main loop where I read stdin and call the parser is below: /***********************************************************************/ /* Read stdin */ /***********************************************************************/ for (;;) { len = (int)fread(buff, 1, BUFFSIZE-1, stdin); if (ferror(stdin)) { fprintf(stderr,"Error reading stdin\n"); exit(-2); } done = feof(stdin); //if nothing read then exit so AI doesnt blow up if ((len == 0) && (done) && (cur_file_num==0)) break; if(XML_Parse(p, buff, strlen(buff), done) == XML_STATUS_ERROR){ fprintf(stderr, "\nParse error at host:%s:file:%d:row:%d:column:%d:reason:%s\n", host, cur_file_num, XML_GetCurrentLineNumber(p), XML_GetCurrentColumnNumber(p), XML_ErrorString(XML_GetErrorCode(p))); fprintf(stderr,"BUFFER = %s\n",buff); exit(-3); } if(done) break; } /* Free memory used by the parser */ if(p) { XML_ParserFree(p); } return 0; } _______________________________________________ Expat-discuss mailing list [email protected] http://mail.libexpat.org/mailman/listinfo/expat-discuss