473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XML Serialization or XMLReader for binary object in VB.NET???

JM
Hello,

Most of the examples I've seen with XMLReaders, serialization, etc,.
involve a text file on a file system. Does anybody have a start to
finish VB.NET example of reading an XML Document object (binary) and
parsing it? The object I'm receiving is w3c compliant. I have
somewhat of a Java example (below), but I would like to know how to do
it in VB.NET. Thank you in advance.

import org.w3c.dom.Document;
import weblogic.apache.xml.serialize.OutputFormat;
import weblogic.apache.xml.serialize.XMLSerializer;
import java.io.StringWriter;

protected String convertDocumentToString(Document argDocument) throws
Exception {
StringWriter sw = new StringWriter();
OutputFormat of = new OutputFormat(argDocument,"UTF-8",false);
XMLSerializer xs = new XMLSerializer(sw,of);
xs.serialize(argDocument);
return sw.toString();
}

Jun 29 '06 #1
2 5491


JM wrote:

Most of the examples I've seen with XMLReaders, serialization, etc,.
involve a text file on a file system. Does anybody have a start to
finish VB.NET example of reading an XML Document object (binary) and
parsing it? The object I'm receiving is w3c compliant. I have
somewhat of a Java example (below), but I would like to know how to do
it in VB.NET. Thank you in advance.

import org.w3c.dom.Document;
import weblogic.apache.xml.serialize.OutputFormat;
import weblogic.apache.xml.serialize.XMLSerializer;
import java.io.StringWriter;

protected String convertDocumentToString(Document argDocument) throws
Exception {
StringWriter sw = new StringWriter();
OutputFormat of = new OutputFormat(argDocument,"UTF-8",false);
XMLSerializer xs = new XMLSerializer(sw,of);
xs.serialize(argDocument);
return sw.toString();
}


Why is a Java org.w3c.dom.Document object "binary"?
The .NET equivalent of the W3C DOM Document is System.Xml.XmlDocument.
If you have an XmlDocument instance then you have various ways to
serialize it, there is the OuterXml property which gives you a string so
you could simply do (VB pseudo code)

Function ConvertDocumentToString (argDocument As
System.Xml.XmlDocument) As String
Return argDocument.OuterXml
End Function

although writing a function at all seems a bit questionable if the
OuterXml property is all you need.

There are other ways, you can use the Save method of the document to
save to a StringWriter e.g. (again VB pseudo code!)

Function ConvertDocumentToString (argDocument As
System.Xml.XmlDocument) As String
Dim string_Writer as System.IO.StringWriter = new
System.IO.StringWriter()
argDocument.Save(string_Writer)
Return string_Writer.ToString()
End Function

Then there is the WriteTo method to write to an XmlWriter which could
also be used to serialize the document.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 29 '06 #2
JM
Martin Honnen wrote:
Why is a Java org.w3c.dom.Document object "binary"?
The .NET equivalent of the W3C DOM Document is System.Xml.XmlDocument.
If you have an XmlDocument instance then you have various ways to
serialize it, there is the OuterXml property which gives you a string so
you could simply do (VB pseudo code)

Function ConvertDocumentToString (argDocument As
System.Xml.XmlDocument) As String
Return argDocument.OuterXml
End Function

<snip>

Martin, thank you for the reply. I guess "binary" was the wrong word
to use. I meant that I was not provided a string containing XML. I've
since found out that what I am being provided is an XMLBean, not an XML
document. Something tells me I cannot add an XMLBean reference to a
VB.NET project, because there is no support yet. Maybe I'm going have
to write a middle piece in Java.

Jun 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jeff T. | last post by:
Hello, I have an existing set of C# classes that encapsulate our application data. They are in a heirachy with each subclass defining more specific types of data. I would like to serialize these...
5
by: Arjen | last post by:
Hello, Can somebody help me a little bit? I can't get it to work. Please see my code below... I have placed some comments like "// And whats next?". I'm sure that I have to code something...
6
by: Uttam | last post by:
Hello, We are at a very crucial decision making stage to select between .Net and Java. Our requirement is to download a class at runtime on the client computer and execute it using remoting or...
3
by: Steve | last post by:
I've been following a couple remoting tutorials on the web, they are all pretty much the same. I've got my different applications built(client, server and remote object (dll)) The client is...
2
by: Maximus | last post by:
Hi Everyone, I was using Inprocess session objects, but incase of aspnet process crashes the session objects were lost as a result I decided to shift to out of porocess session objects. For this...
0
by: umhlali | last post by:
I get the following exception when my VB.NET app calls a Java web service that returns an array of objects. The same call works for a single object though. So looks like there is no problem...
0
by: hic78 | last post by:
Hi, I use a proxy class to invoke web service developed in SOAP/Java: using System.Diagnostics; using System.Xml.Serialization; using System; using System.Web.Services.Protocols; using...
2
by: JM | last post by:
Hello, Most of the examples I've seen with XMLReaders, serialization, etc,. involve a text file on a file system. Does anybody have a start to finish VB.NET example of reading an XML Document...
5
by: Nikola Skoric | last post by:
I ran in Mono a program developed on .NET Framework 2.0 and it ran OK until I tried to desirialize a object. There the program died abruptly dumping this: System.ArgumentOutOfRangeException:...
8
by: =?Utf-8?B?UGlnZ3k=?= | last post by:
Hi to all, I am getting this System.OutOfMemoryException calling the Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(<stream>,<Obj>) method. The type of <streamis...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.