示例#1
0
        /**
         * Serializes a XML document to a byte array.
         * @param n the XML document
         * @throws java.io.IOException on error
         * @return the serialized XML document
         */
        public static byte[] SerializeDoc(XmlNode n)
        {
            XmlDomWriter xw   = new XmlDomWriter();
            MemoryStream fout = new MemoryStream();

            xw.SetOutput(fout, null);
            xw.SetCanonical(false);
            xw.Write(n);
            fout.Close();
            return(fout.ToArray());
        }
示例#2
0
        /**
         * Writes the document to a byte array.
         */
        virtual public byte[] SerializeDoc()
        {
            XmlDomWriter xw   = new XmlDomWriter();
            MemoryStream fout = new MemoryStream();

            xw.SetOutput(fout, null);
            byte[] b = new UTF8Encoding(false).GetBytes(XPACKET_PI_BEGIN);
            fout.Write(b, 0, b.Length);
            fout.Flush();
            XmlNodeList xmpmeta = domDocument.GetElementsByTagName("x:xmpmeta");

            xw.Write(xmpmeta[0]);
            fout.Flush();
            b = new UTF8Encoding(false).GetBytes(EXTRASPACE);
            for (int i = 0; i < 20; i++)
            {
                fout.Write(b, 0, b.Length);
            }
            b = new UTF8Encoding(false).GetBytes(XPACKET_PI_END_W);
            fout.Write(b, 0, b.Length);
            fout.Close();
            return(fout.ToArray());
        }
示例#3
0
 /**
  * Writes the document to a byte array.
  */
 public byte[] SerializeDoc()
 {
     XmlDomWriter xw = new XmlDomWriter();
     MemoryStream fout = new MemoryStream();
     xw.SetOutput(fout, null);
     byte[] b = new UTF8Encoding(false).GetBytes(XmpWriter.XPACKET_PI_BEGIN);
     fout.Write(b, 0, b.Length);
     fout.Flush();
     XmlNodeList xmpmeta = domDocument.GetElementsByTagName("x:xmpmeta");
     xw.Write(xmpmeta[0]);
     fout.Flush();
     b = new UTF8Encoding(false).GetBytes(XmpWriter.EXTRASPACE);
     for (int i = 0; i < 20; i++) {
         fout.Write(b, 0, b.Length);
     }
     b = new UTF8Encoding(false).GetBytes(XmpWriter.XPACKET_PI_END_W);
     fout.Write(b, 0, b.Length);
     fout.Close();
     return fout.ToArray();
 }