473,383 Members | 1,846 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,383 software developers and data experts.

Deserialize multiple XML documents

2
Hi All,

I have a TCP Client which reads the data from the socket. Now I have to deserialize the received data. The data can contain multiple XML documents like :

<customer field="value">
<address>road 11<address/>
<customer/>
<supplier>
<goods>printers<goods/>
<supplier/>

In this case I want to deserialize customer and secondly the supplier. I know how I deserialize each individual document as long as I know which document should be deserialized. Ofcourse, I can check the name of the root tag and fire the applicable deserialization function. But I hope there is a more generic way to do this.

Thanks for your help in advance
Jul 31 '08 #1
2 1468
TTCEric
26
is that the data as recieved from the socket?
i think all you need to do is get an XML reader and use that as long as its relatively well-formed.
but you mention deserialize. thats taking objects passed between domains and using them as objects in your code. in this case you seem to have the data deserialized already.
all you need now is an xml object to get to the element you need.
Jul 31 '08 #2
jonker
2
The data is directly received from the socket. The problem is that each message has a different structure and its own root node.

OK, I can't deserialize multiple root nodes, but I can detect a full message and parse the single message.

At the moment of deserialization you have to specify the type of the target object.
XmlSerializer xs = new XmlSerializer(typeof(customer));

Since this can be multiple objects (customer of supplier) I can't use this method. How can I solve this issue? As said by multiple functions or is there a generic way ?

The input format is specified by a 3th party, so I can't modify the structure :-(
Jul 31 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Ian Tompsett | last post by:
H I was wondering if it possible for an object to serialize/deserialize itself from XML. I'd be guessing that it would need to use the XmlSerializer class, but that seems to want to create a...
2
by: Hollywood | last post by:
After doing a search through google's archives of this list, I didn't see what I was looking for so here goes... Is it possible to serialize/deserialize multiple objects from a single XML file? ...
19
by: Sharon | last post by:
Hi, When I'm doing BinaryFormatter.Deserialize() over a TCP socket. When I'm closing the TcpListener by invoking the TcpListener.Stop(); I get: System.IO.IOException with message "Unable to...
17
by: Peter | last post by:
How would would you deserialize this example below? Imports System Imports System.Collections Imports System.IO Imports System.Xml.Serialization Public Class App1 Shared Sub Main()
3
by: Jeff Richardson | last post by:
This is a repost from the InfoPath news group. Hi, I am writing a SharePoint application that works with InfoPath forms. When a user submits a completed InfoPath form to a forms library my code...
2
by: Thomas S | last post by:
Any suggestions on how to deserialize an object from one line of XML? I'm trying to deserialize multiple objects from one XML document, each object on one line of the file. The serialization is...
0
by: anchiang | last post by:
Hi All, I have XML: <RegistryResponse status="Success" xmlns="urn:oasis:names:tc:ebxml-regrep:registry:xsd:2.1"> <AdhocQueryResponse xmlns="urn:oasis:names:tc:ebxml-regrep:query:xsd:2.1"> ...
3
by: BillyZ313 | last post by:
I am trying to Deserialize an xml to a C# object so i can use it efficently. I have done this with much less complex xml documents so i gave it a shot and it fails on Deserialize call with no good...
0
Pittaman
by: Pittaman | last post by:
Hello, We're developing an application (.NET 2.0) that let's users drop documents in the application and allows users to show some document types "embedded". For example, a textfile would appear...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
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...

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.