473,396 Members | 2,068 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,396 software developers and data experts.

xml deserialization help

Simple deserialization help needed please...

I have a packet of xml in a string, and need to get that into a
reader./stream of some sort so I can properly use deserialize..

here's my deserialization routine (its part of a property as you can tell)..

Set(ByVal Value As String)
Dim serializer As New XmlSerializer(GetType(Package))
Dim xmlstream As New MemoryStream
Dim oPackage As Package
Dim strXML() As String
Dim strChar As String
Dim bytXML() As Byte
Dim byt As Byte

' All the code in here I removed because it was a debugging and testing
jumble of garbage
' How do I got from the XML data in Value, and get that into a memory
stream, or something that the serializer will deserialze?

oPackage = CType(serializer.Deserialize(xmlstream), Package)

End Set
The data I'm trying to deserialize is (this is the Value string in the Set
above):
<?xml version="1.0"?>
<Package xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID>ffec2923-e125-4693-905b-d88888c7522f</ID>
<Action>Send Message</Action>
<Data>my message</Data>
<ReceiptRequired>false</ReceiptRequired>
<Sent>2004-02-11T13:58:53.8150490-06:00</Sent>
<Source_UserLogin>test</Source_UserLogin>
<Source_UserID>ffe5f6ef-b046-4456-b140-9412345b8f47</Source_UserID>
<Source_ComputerName>shadow</Source_ComputerName>
<Source_ComputerIP>192.1.111.3</Source_ComputerIP>
<Target_UserLogin>test</Target_UserLogin>
<Target_UserID>29e5f6ef-b146-46b5-b140-94cf6666f47</Target_UserID>
<Target_ComputerName>localhost</Target_ComputerName>
<Target_ComputerIP>127.0.0.1</Target_ComputerIP>
</Package>
Nov 12 '05 #1
1 2068
"Tom L" <tlanger_n05p4m_dls.net> wrote in message news:3e********************@dls.net...
Set(ByVal Value As String)
Dim serializer As New XmlSerializer(GetType(Package)) : : Dim oPackageAs Package : : ' How do I got from the XML data in Value, and get that into a memory
stream, or something that the serializer will deserialze?

oPackage = CType(serializer.Deserialize(xmlstream), Package)


The most direct means is just to wrap the String in a StringReader
(Deserialize will work with any TextReader subclass), don't worry
above using a Stream.

oPackage = CType( serializer.Deserialize( New StringReader( Value)), Package)

BTW, creating an XmlSerializer on every set is an expensive
proposition. I'd recommend at least moving the XmlSerializer
to a Shared field in the class containing this property.
Derek Harmon
Nov 12 '05 #2

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

Similar topics

2
by: Snowman | last post by:
Suppose I have a RootObject which holds a collection of other objects. The other objects have a property (Parent) which refers back to the "parent" collection (b.t.w. my collection is based on...
4
by: Mike Sarbu | last post by:
Hello all, I have an XML file like this: <?xml version="1.0" encoding="utf-8"?> <SomeObject xmlns="http://www.abcinc.com/objectdefinition"...
3
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database...
3
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
2
by: andreas | last post by:
Hi, if have a object arrSdList of type SortedList for serialization and deserialization there are two subs for doing this Public Sub deser Dim Formatter As BinaryFormatter = New...
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
1
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client...
8
by: ashoksrini | last post by:
Hi All, I have the below requirement and would like to get some feeback from the group on the best way to implement: 1. I have WSDL defined exposing few web services. 2. We dont have a...
12
by: yoshijg | last post by:
Is there a way to be notified when the deserialization of an XML is complete, like a callback method? I tried the IDeserializationCallback interface, but that doesnt for XML-Deserialization. ...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.