R
R
Hello everybody.
I have a problem with fatal error while parsing XML.
I have a server and a client.
My server creates XML from web page given by the client, after parsing
it to
XML the content is being sent to client.
this is client code:
// read text from socket
while (null != line)
{
sb.append(line);
line = br.readLine();
}
// debug - this works I can see my XML response!
// System.out.println(sb.toString());
// parse my String back to DOM Document
DocumentBuilder xdb2 = XMLParserUtils.getXMLDocBuilder();
ByteArrayInputStream bais = new
ByteArrayInputStream(sb.toString().getBytes());
Document doc = xdb.parse(new InputSource(bais));
and then I recieve this fatal error:
[Fatal Error] :1:1335: Invalid byte 1 of 1-byte UTF-8 sequence.
org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
at
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)
at
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
How can I avoid this problems?
Should I encode (how?) text sent through sockets?
thanks in advance for Your help
best regards
R
I have a problem with fatal error while parsing XML.
I have a server and a client.
My server creates XML from web page given by the client, after parsing
it to
XML the content is being sent to client.
this is client code:
// read text from socket
while (null != line)
{
sb.append(line);
line = br.readLine();
}
// debug - this works I can see my XML response!
// System.out.println(sb.toString());
// parse my String back to DOM Document
DocumentBuilder xdb2 = XMLParserUtils.getXMLDocBuilder();
ByteArrayInputStream bais = new
ByteArrayInputStream(sb.toString().getBytes());
Document doc = xdb.parse(new InputSource(bais));
and then I recieve this fatal error:
[Fatal Error] :1:1335: Invalid byte 1 of 1-byte UTF-8 sequence.
org.xml.sax.SAXParseException: Invalid byte 1 of 1-byte UTF-8 sequence.
at
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:264)
at
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
How can I avoid this problems?
Should I encode (how?) text sent through sockets?
thanks in advance for Your help
best regards
R