List Info

Thread: Parsing problem




Parsing problem
user name
2006-07-23 13:31:10
Hi,

I hope this it the right list for this type of cuestions.
Im writing a client/sever application and I have a problem I can't understand. The sever dumps a xml document using the folowing code:

xmlDocPtr     doc;
xmlChar     *text;
int         size;
...  
xmlDocDumpMemory(doc, &text, &size);

this is then sent over a socket an is parsed by the client with the following conde:

char *str;
xmlDocPtr doc;
...
doc = xmlParseDoc((const xmlChar*)str);

when I run this I get the folowing error:

Entity: line 2: parser error : Specification mandate value for attribute node
<xmlSend>&lt;test node/>&lt;/xmlSend>
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp;  ^

Where the '^' is pointing to the  '/' in <test node/>.
I have tried to find out what the message means on the web site but with out any lyck.
What am I doing wrong? What do the error message mean?

/Ola
Parsing problem
user name
2006-07-23 13:45:39
On 23.07.06 15:31:10, Ola Bodin wrote:
> xmlDocPtr     doc;
> xmlChar     *text;
> int         size;
> ...
> xmlDocDumpMemory(doc, &text, &size);
> 
> this is then sent over a socket an is parsed by the
client with the
> following conde:
> 
> char *str;
> xmlDocPtr doc;
> ...
> doc = xmlParseDoc((const xmlChar*)str);

Did you try to use xmlParseDoc directly on the server?

> Entity: line 2: parser error : Specification mandate
value for attribute
> node
> <xmlSend><test node/></xmlSend>
>
> Where the '^' is pointing to the  '/' in <test
node/>.
> I have tried to find out what the message means on the
web site but with out
> any lyck.

Of course, because the error is that the XML contained in
the char* is
not valid. You cannot have a xml node with a name containing
underscores. Thus "<test node/>" is parsed
as XML node with the name
"test" and an attribute named
"node", however it has no value and this
is also forbidden by XML - attributes need to have a value.

So either the construction of your DOM is wrong (in which
case libxml2
should've complained already upon serialization, I think)
or something
goes wrong during the transport over the wire.

To exclude the first possibility I'd suggest to include
some testing
code inside the server app that takes the content of *text
and tries to
parse it via xmlParseDoc.

Andreas

-- 
You learn to write as if to someone else because NEXT YEAR
YOU WILL BE
"SOMEONE ELSE."
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )