Better approach for XML Creation in Blackberry

前端 未结 3 1987
滥情空心
滥情空心 2020-12-01 13:54

I have created XML file,but I can\'t view it/output it.I know there is no way to output created XML file.

Can anyone please suggest what is better way of creating xm

3条回答
  •  情书的邮戳
    2020-12-01 14:17

    What about using the DOMInternalRepresentation class? Despite its name, it's part of the public API and has existed since JDE 4.0.0. Using the DOMInternalReprestationClass you can write the Document to an XMLWriter.

    For example, to write to a ByteArrayOutputStream (making it handy to send over a Connection):

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    XMLWriter xw = new XMLWriter(os);
    DOMInternalRepresentation.parse( myDocument, xw );
    

    Naturally, you can use a FileOutputStream to direct the XML output to a file on disc instead of to a byte-array.

    (If you can't use external libraries for some reason, this seems like a pretty viable approach)

提交回复
热议问题