what i am trying to do is using a client-side application(C#) collect customer information and generate a xml stream (using XMLTextWriter), after that post the stream using webhttprequest send to a domino server. in server side I write a servlet to received the stream and using parser(ibm xmlparser) to transform the information to a Domino document and store it.
I have successed post the xml stream to servlet and create a domino document.
but now there is a problem when I try to insert a data to a RTF field
(Rich text Field).
I want to konw why when i create a xml file using XMLTextWriter in C# the file always start with some symbol like "?" "-" . although we can not see this kind of symbol from IE(because we can using IE open the xml file, and there is no error).
if using java open the file
for example I using followwing method
URL url=new URL("http://localhost/Temp.xml");
InputStream input=url.openStream();
String line;
while((line=input.readLine())!=null)
{
System.out.println(line);
}
the output will like this
?<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE BOOK[
<!ELEMENT BOOK (ALL)>
<!ELEMENT TITLE (#PCDATA)>
<!ELEMENT PUBLICATION_DATE (#PCDATA)>
<!ELEMENT ISBN_NO (#PCDATA)>
<!ELEMENT AUTHOR (NAME,GENDER)>
<!ELEMENT NAME (#PCDATA)>
<!ELEMENT GENDER (#PCDATA)>
<!ELEMENT PRICE (#PCDATA)>
]>
<BOOK>
<TITLE>sf</TITLE>
<PUBLICATION_DATE>kjjk</PUBLICATION_DATE>
<ISBN_NO>jjk</ISBN_NO>
<AUTHOR>
<NAME>gdfk</NAME>
<GENDER>dkfj</GENDER>
</AUTHOR>
<PRICE>jj</PRICE>
</BOOK>
following is what i have finished in coding
please help me is here more efficient way to do post or received method
in C#(client)
....
string uri=txtUri.Text;
WebRequest req=WebRequest.Create(uri);
req.Timeout=120000
req.Method="POST";
req.ContentType="text/xml";
Stream stream=req.GetRequestStream();
xtw.Formatting=Formatting.Indented;
xtw.WriteStartDocument();
xtw.WriteDocType("BOOK",null,null,subset);
xtw.WriteStartElement("BOOK");
xtw.WriteElementString("TITLE",bookTitle);
xtw.WriteElementString("PUBLICATION_DATE",publicat ionDate);
xtw.WriteElementString("ISBN_NO",isbnNo);
xtw.WriteElementString("GENRE",genre);
xtw.WriteStartElement("AUTHOR");
xtw.WriteElementString("NAME",authorName);
xtw.WriteElementString("GENDER",gender);
xtw.WriteEndElement();
xtw.WriteElementString("PRICE",price);
xtw.WriteEndElement();
xtw.WriteEndDocument();
xtw.Flush();
xtw.Close();
...
in servlet (server)
.....
java.io.InputStream input=request.getInputStream();
FileOutputStream fos=new FileOutputStream("C:\\Temp.xml");
int c;
while ((c = input.read()) != -1) {
fos.write(c);
}
input.close();
fos.close();
com.ibm.xml.parser.Parser ibmParser=new com.ibm.xml.parser.Parser("C:\\Temp.xml");
InputStream input2 =new FileInputStream("C:\\Temp.xml");
org.w3c.dom.Document orgDoc=ibmParser.readStream(input2);
Element element=orgDoc.getDocumentElement();
input2.close();
......
anyway please forgive me my poor english!
thank you very much for your help
yang
|