|
|
|
date: Fri, 27 Jun 2008 09:44:49 -0700 (PDT),
group: microsoft.public.dotnet.vjsharp
back
Re: XMLDocument and java.io.InputStream
It doesn't look like anyone visits this group, so I thought I'ld
record what I found out...
I'm trying to write an application that updates the text inside of
a .docx word document, without using Microsoft Word.
Word compresses .docx files through the zip algorithm. My application
is written in VB.NET 2003 which doesn't have any zip libraries like
those found in VB.NET 2005 or later to decompress/compress files.
But, J Sharp that ships with Visual Studio 2003 does offer zip
functions that can be called from VB.NET programs.
When you decompress a docx file, you will find it contains multiple
files, one of which is the text branch of the word document. This
file is word\document.xml, and it can be loaded into a xmlDocument DOM
parser. You can then modify the content of the nodes in this document
and save it back out to the zip file. Unfortunately, all the zipping
is done through stream copying defined by java.io classes. The
xmlDocument object doesn't have any methods that allow it to work with
java.io classes. The xmlDocument object does provide its content in
the form of a string through its outerXML method. The J Sharp
documentation basically says you have to write your own custom string
streaming class using the StringReader object.
Fortunately, J Sharp 2003 still supports the depreciated
java.io.StringBufferInputStream object. StringBufferInputStream is
able to stream System.String objects. But, it can only do this with
regular ascii text and not unicode. So, as long as the data in the
xmldocument is encoded in UTF-8, the StringBufferInputStream object
should work.
ie srcStream = New java.io.StringBufferInputStream(docXML.OuterXml)
date: Fri, 27 Jun 2008 11:07:16 -0700 (PDT)
author: Andy
|
|