Make sure the coded character set id of the file expat is reading matches the ISO-8859-9 encoding. The parser should be using the encoding, but IBMi is translating (or not) based on the CCSID value in the file descriptor. I'm not familiar with 8859-9. For 8859-1, character set 819 works. To see CCSID, use WRKLNK option 8.
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of cevdet macit
Sent: Thursday, January 12, 2012 8:55 AM
To: midrange-l
Subject: expat XML parsing problem,CPF9897: Parse error at line 1: unknown encoding
Hi all,
My program reads an .xml file from ifs and parses it . I am using Scott Klement's expat tool.(And thanks to him very much).
The program opens and reads the file but can not parse it. I get CPF9897: Parse error at line 1: unknown encoding message whenever i run the program.
this is the line error occurs: if (XML_Parse(p: Buff: len: done) = XML_STATUS_ERROR);
I think my .xml file does not have a syntax problem.Because I've validated the it by
http://www.w3schools.com/xml/xml_validator.asp.
.Xml file header: <?xml version="1.0" encoding="ISO-8859-9"?> .
The xml file can be accessed at
http://www.tcmb.gov.tr/kurlar/today.xml.
I think i am doing a very basic mistake.I could not find out what i've been doing wrong,any help is appreciated.
Thanks in advance
Cevdet
Main part of my rpg code:
/free
fd = open('/tmp/tcmb_kur.xml': O_RDONLY+O_TEXTDATA);
if (fd < 0);
EscErrno(errno);
endif;
p = XML_ParserCreate(XML_ENC_ISO8859_1);
if (p = *NULL);
callp close(fd);
die('Couldn''t allocate memory for parser');
endif;
XML_SetStartElementHandler(p: %paddr(start));
XML_SetEndElementHandler(p: %paddr(end));
XML_SetCharacterDataHandler(p: %paddr(chardata));
dou (done = 1);
len = read(fd: %addr(Buff): %size(Buff));
if (len < 1);
done = 1;
endif;
if (XML_Parse(p: Buff: len: done) = XML_STATUS_ERROR);
callp close(fd);
die('Parse error at line '
+ %char(XML_GetCurrentLineNumber(p)) + ': '
+ %str(XML_ErrorString(XML_GetErrorCode(p))));
endif;
enddo;
XML_ParserFree(p);
callp close(fd);
*inlr = *on;
/end-free
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.