Thanks to all of you...
1/ Any idea about how to make that in C++ ?
2/ Here is a simple source code that could help newbyes if needed...
/**
* bufferDemo() takes all data from a buffer and counts item. This demo
shows
* how a buffer can be processed after a TCP/IP transfer or after being
* extracted from a file, etc.
*/
private static int bufferDemo () {
int status = 0;
Document dBuffer;
int iElementCount;
StringReader srXMLData;
DOMParser pBuffer = new DOMParser();
InputSource isXMLData = new InputSource();
StringBuffer sbXMLData = new StringBuffer();
sbXMLData.append("<?xml version=\"1.0\"?>\n");
// XML Feeding ...
sbXMLData.append("</personnel>\n");
System.out.println("Buffer contains :\n" + sbXMLData.toString());
// Create a StringReader to similute a stream on a buffer
srXMLData = new StringReader (sbXMLData.toString());
// Associate an InputSource to a StringReader
isXMLData.setCharacterStream (srXMLData);
try {
pBuffer.parse(isXMLData);
}
catch (Exception e) {
System.err.println(e.toString());
status = -1;
}
if (status == 0) {
dBuffer = pBuffer.getDocument();
iElementCount = dBuffer.getElementsByTagName("*").getLength();
System.out.println ("Found " + iElementCount + " elements.");
}
return status;
} // bufferDemo
Jean Georges PERRIN
--
Four J's Development Tools (www.4js.com)
[EMAIL PROTECTED] - Tel +33 (0)3 88 18 61 20 - Fax +33 (0)3 88 18 61 21
--
CAUTION: import com.fourjs.StandardDisclaimer;
> -----Original Message-----
> From: Scott Sanders [mailto:[EMAIL PROTECTED]
> Sent: Thursday, February 17, 2000 18:33
> To: [EMAIL PROTECTED]
> Subject: Re: [Java|1.0.1] Parsing from StringBuffer...
>
>
> Thanks. I'll give it a try ;-)
>
> >(in this example doc is the Document for the DOM tree)
> >
> > public void print(Writer out,String encoding) {
> > XMLSerializer xser = new XMLSerializer();
> > xser.asDOMSerializer();
> > xser.setOutputCharStream(out);
> > OutputFormat of = new OutputFormat(doc,encoding,true);
> > xser.setOutputFormat(of);
> > try {
> > xser.serialize(doc);
> > }
> > catch (IOException e) {
> > e.printStackTrace();
> > }
> > }
> >
> > Do you have a quick example?
> >
> > > I've done it by using the serializer classes and serializing to a
> > > java.io.StringWriter.
> > >
> > > - Greg
> > >
> > > Is there something like that to do the opposite, ie, given a DOM tree,
> how
> > > do I get it into a single String or StringBuffer.
> > >
> > > > create a java.io.StringReader, then create a org.xml.sax.InputSource
> > from
> > > > the StringReader. Pass the input source into the parse() method and
> you
> > > are
> > > > home free.
> > >
> > > >> I have some data in a StringBuffer. These data are XML. I'd like to
> > parse
> > > >> them. How can I "feed" the DOM parser wo/ writing a file ?
>
>