|
|
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Bug in xml parser?
Bug in xml parser? [message #27272] |
Fri, 09 July 2010 22:55 |
aftershock
Messages: 143 Registered: May 2008
|
Experienced Member |
|
|
Hi,
I wonder if there is bug in xml parser because of the following problem.
I use XMLRPC package.
I debuged the package. I can see this.
The server returns an xml which something like this:
<value><string>line1\nline2\nline3\n</string></value>
The parser returns a string which is "line1\nline2\nline3" without the final \n.
My question is .. Is this bug if the xml parser does not return the final \n?
It looks so.
This is how I fixed it:
Add this line to xmlparser class definition:
void Preserve(bool b) { npreserve = b; }
Modified xmlrpc\client.cpp
This is the result of changes around line 65.
if(IsNull(response)) {
faultCode = XMLRPC_CLIENT_HTTP_ERROR;
faultString = server.GetError();
error = "Http request failed: " + faultString;
LLOG(error);
return ErrorValue(error);
}
XmlParser p(response);
p.Preserve(true); //<-- new line
try {
[Updated on: Sat, 10 July 2010 10:12] Report message to a moderator
|
|
|
|
|
|
Re: Bug in xml parser? [message #27551 is a reply to message #27292] |
Fri, 23 July 2010 10:46 |
|
mirek
Messages: 14038 Registered: November 2005
|
Ultimate Member |
|
|
aftershock wrote on Sun, 18 July 2010 05:12 |
luzr wrote on Sun, 18 July 2010 10:03 |
aftershock wrote on Mon, 12 July 2010 12:27 | I think this is the fix
void XmlParser::Next()
{
nattr.Clear();
nattr1 = nattrval1 = Null;
if(empty_tag) {
empty_tag = false;
type = XML_END;
return;
}
text.Clear();
type = XML_EOF;
if (!(npreserve || preserveall)) //<-- this should be added
SkipWhites();
The problem is the initial whitespace and EOL is thrown away which is not good.
Your other fix seems to be ok.
Have a good day!
Marton
|
Hi,
I had to revert this patch as it completely breaks any existing XML code.
I suggest you to send me some testcase demonstrating XML that needs XmlParser to be fixed, I will try to find some workaround.
Mirek
|
It was not my intention Really? How does it break them?
E.g
<value> myvalue</value>
This should return " myvalue" if it is read..
Marton
|
That is not a problem. The trouble is that when active, it will not skip any whitespaces in between tags, so:
cannot be parsed with
if(Tag("tag1") && Tag("tag2"))
as there is now Text element in between....
Sure, perhaps we might try to alter parser philosophy, but at this point I think that would be dangerous and we should try to find another solution first...
Mirek
(reposting back to forum to eventually gather more comments).
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 03:45:04 CEST 2024
Total time taken to generate the page: 0.06533 seconds
|
|
|