473,804 Members | 3,509 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlSerializatio n to XmlNode

I have a schema that I load into classes that mirror the schema using
the XmlSerializatio n. The schema contains an xsd:Any that I load into
'Extra' as follows:

[XmlElement(Elem entName="Extra" )] public XmlNode Extra { get { return
extra;} set { extra = value;}}

However, if I have:

<Something>
<Extra>
<a>something</a>
<b>another thing</b>
</Extra>
</Something>

I would expect Extra to contain an XmlNode of :

<Extra>
<a>something</a>
<b>another thing</b>
</Extra>

But it doesn't : it contains :

<a>something</a>

Is there any attributes etc I can set to get the full element to be
retained ?

TIA

Dominic
Nov 12 '05 #1
1 1407
Yes, when I use

// [XmlElement(Elem entName="Extra" )]
[XmlAnyElement]
public System.Xml.XmlE lement Any;

I get the behavior you seek.
note: the attribute is XmlAnyElement, not XmlElement. Also, omit the name.
If you want to allow more than one element, like so:

<Something>
<Extra>
<a>something</a>
<b>another thing</b>
</Extra>
<foo/>
<bar>
<blah/>
</bar>
</Something>

then specify an array:
[XmlAnyElement]
public System.Xml.XmlE lement[] Any;

-Dino
"Dominic Messenger" <dm********@ver dantsys.com> wrote in message
news:9d******** *************** ***@posting.goo gle.com...
I have a schema that I load into classes that mirror the schema using
the XmlSerializatio n. The schema contains an xsd:Any that I load into
'Extra' as follows:

[XmlElement(Elem entName="Extra" )] public XmlNode Extra { get { return
extra;} set { extra = value;}}

However, if I have:

<Something>
<Extra>
<a>something</a>
<b>another thing</b>
</Extra>
</Something>

I would expect Extra to contain an XmlNode of :

<Extra>
<a>something</a>
<b>another thing</b>
</Extra>

But it doesn't : it contains :

<a>something</a>

Is there any attributes etc I can set to get the full element to be
retained ?

TIA

Dominic

Nov 12 '05 #2

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

Similar topics

2
3455
by: STom | last post by:
I have just started reading up on XMLSerialization and still do not understand the practical use of this technology. For example, if I have to know the class type on the client and on the web service side, wouldn't it be easier to just use .Net remoting? I envision some point of passing over the XML document but the web service not really knowing about the objects type. Am I way off base with my perceptions?
3
8121
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to run the class it gives an error that "System.Xml.XmlNode.XmlNode() is inaccessible due to its protection level". This error comes because XmlNode has not any public constructor. I found XmlNode has two constructor but both are private or friend...
5
2144
by: Mahesh Devjibhai Dhola | last post by:
Hi All, I want to make a custom class in c#, which extends System.Xml.XmlNode class of BCL. Now in custom class, I have implement abstract methods of XmlNode class also. Now when I am trying to run the class it gives an error that "System.Xml.XmlNode.XmlNode() is inaccessible due to its protection level". This error comes because XmlNode has not any public constructor. I found XmlNode has two constructor but both are private or friend...
0
2057
by: A programmer desperatly needing help! | last post by:
I use the xmlserialization on asp.net pages and on previous machines it never gave a problem. But now i somethings get a: Timed out waiting for a program to execute. The command being executed was "c:\winnt\microsoft.net\framework\v1.1.4322\csc.exe" /noconfig @"C:\DOCUME~1\...\ve3y0f-a.cmdline" error. It happens at random but occurs mostly when calling the XMLserialization multiple time rapidly. While looking at the .out file the error...
4
4019
by: pfrisbie | last post by:
I am developing a Web Services interface with C# and our partner is using Java (Axis 1.1). They require me to include xsi:types in the SOAP Messages I send them. For example: <Partner xmlns="urn:partner.xxxxx.com"> <RequestID>239</RequestID> <TimeStamp>2006-03-06T17:10:51.4662331-06:00</TimeStamp> <Subject xmlns:ns1="urn:partnermapping.xxxxxx.com" xsi:type="ns1:PartnerMapping"> <AccountID>98401</AccountID>
3
1066
by: Joe Cool | last post by:
I have an XML file that is created by an application that I do not have the source to and have no control over at all. I would like to read this XML file using VS2005 VB with XMLSerialization. The following XML file exhibits the structure of this file: <Root> <Group> <TypeA Attrib1="xxx" Attrib2="xxx"> <TypeAProperty1>xxx</TypeAProperty1> <TypeAProperty2>zzz</TypeAProperty2>
3
6990
by: LW | last post by:
Hi! I am getting the following error message for my fairly simple web service. I have classes and have two DataSets that reference the same classes. The error is: The XML element named 'GetCustNoResponse' from namespace 'http://mydomain/' references a method and a type. Change the method's message name using WebMethodAttribute or change the type's root element using the XmlRootAttribute.
1
3967
by: Frank | last post by:
Hi, Let's say I have a file named myFile.xml Within that file I have blocks of data which I'd like to add at different times during the day. e.g. <LogEntry>
0
3964
by: IanWright | last post by:
This is a little bit more of an advanced topic for serialization. For those who don't know what XML serialization is, then this probably isn't for you just yet. For those that do, you may have come across the problem of serializing an interface, something that you simply can't do using the standard XmlSerialization techniques. This articles looks at how to do that, although it might be a little length. Lets take the following problem: ...
0
9708
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10589
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10327
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.