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

information on IXmlSerializable interface

Hello All,
I want to deserialize part of xml into a object. For this i am
having class that implements the IXmlSerializable interface. For this
class i get the xmlnode object that has the xml.

How do i read this xmlnode object in the readxml of
IXmlSerializable ? as the ReadXml has the xmlreader object as as
input. How do i associate the xmlreader to xmlnode so that i can go
ahead with reader.read().

Any help would be highly appreciated.

Thanks & Regards,
Sachin naik.

May 13 '07 #1
2 1810
Hi,

If your goal is to feed an XmlNode into an XmlReader you may be able to
do this using the code below:

using System.IO;
using System.Text;
using System.Xml;

....

XmlNode node = GetNodeFromSomewhere();

using(MemoryStream ms = new MemoryStream())
{
byte[] nodeData = Encoding.Default.GetBytes(node.OuterXml);
ms.Write(nodeData);

using(XmlReader xr = XmlReader.Create(ms))
{
// Do something with the reader.
}
}

I haven't tested this for Xml serialization so I cannot guarantee this
will work for you.
On Sun, 13 May 2007 11:07:26 +0200, sachy <sa***********@gmail.comwrote:
Hello All,
I want to deserialize part of xml into a object. For this i am
having class that implements the IXmlSerializable interface. For this
class i get the xmlnode object that has the xml.

How do i read this xmlnode object in the readxml of
IXmlSerializable ? as the ReadXml has the xmlreader object as as
input. How do i associate the xmlreader to xmlnode so that i can go
ahead with reader.read().

Any help would be highly appreciated.

Thanks & Regards,
Sachin naik.



--
Happy coding!
Morten Wennevik [C# MVP]
May 13 '07 #2
Can you clarify your intent? The most efficient way to handle xml is
directly via the reader/writer, as you don't need to fill an entire
DOM (such as XmlDocument) - however, I appreciate that this isn't
always the most convenient. If you simply want to treat the reader as
a DOM, then perhaps create an XmlDocument and Load() from the reader.
This is fine for most xml - but gets painful for very large xml.

Marc

May 13 '07 #3

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

Similar topics

1
by: Leepe | last post by:
example: I have a skill object that implements the XmlSerializable interface Implementing the getschema gives me some unwanted generations towards the wsdl.exe Reference.cs generation. skill is...
1
by: mattoc | last post by:
Happy new year to all. I have a strange error that I've been trying for a while now to fathom.. Basically I have a hierarchy of state classes that I need to serialize to XML. Some of them can...
1
by: theburnetts | last post by:
I have a complex class heirarchy where all of my classes inherit from a single base class (BaseObject) and this BaseObject class inherits from XPBaseObject. XPBaseObject is a 3rd party base class...
1
by: Peter Nofelt | last post by:
Hey All, I am having issue with serializing a class and its base class using ..net 2.0. I am using IXmlSerializable I've provided code displaying my at the bottom of this post. Thanks ahead...
3
by: John Glover | last post by:
To whoever can help, I've been having a problem with XML deserialization lately. I needed to serialize and deserialze two objects which inherited from Hashtable. Because IDictionary...
0
by: Marek | last post by:
Hi I have an object model which includes a Dictionary<> property which I am trying to serialize/deserialize using IXmlSerializable as follows class X:IDictionary<a,b>,IXmlSerializable) What...
0
by: Jamie | last post by:
I've implemented 3 classes, all of which make use of the IXmlSerializable interface. Class A has 2 properties that are instances to class B and C. Class A - serialization routine: public...
0
by: burningmidget | last post by:
I am having trouble using IXmlSerializable within a base class and having xsi:type work correctly when deserializing an xml file. Here is a very simplified version of the what is going on in the...
2
by: =?Utf-8?B?Ym9iYnk=?= | last post by:
I whave a custom membershipProvider which inherits from MembershiopUser also I want to implement IXmlSerializable. Is my following code correct. public class SSOMembershipUser :...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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.