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

trouble with serializing a class into xml

I am having trouble getting a class to serialize the way I want it to.
I'm open to changing the class or dumping it altogether; I just need a way
to produce the last set of xml.

The following code produces the first set of xml.
I have tried to set the attributes of the myXmlNode class to produce the
last set of xml but I can't figure it out.
Can the last set of xml be achieved?

TIA!

[XmlRoot("Root",Namespace="http://my.ns.com")]
public class myXmlNode
{
public string[] ID;
}

/////////
[WebMethod]
public myXmlNode HelloWorld()
{
myXmlNode n = new myXmlNode();
//some db code
n.ID= new string[100];
int ord= 0;
while(rdr.Read())
{
id = (string)rdr.GetSqlString(0);
n.ID[ord] = id;
ord++;
}
rdr.Close();
return n;
}


This is what I'm getting:

<?xml version="1.0" encoding="utf-8" ?>
<Root xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://my.ns.com">
<ID>
<string>9780486406510</string>
<string>9780760748718</string>
<string>9781593081386</string>
<string>9781593083328</string>
<string>9780452274426</string>
<string>9780060934415</string>
<string>9781593080556</string>
<string>9780375701429</string>
<string>9780812574920</string>
<string>9780451526564</string>
<string>9780060197353</string>
</ID>
</Root>


This is what I want:

<?xml version="1.0" encoding="utf-8" ?>
<Root xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://my.ns.com">
<ID>9780486406510</ID>
<ID>9780760748718</ID>
<ID>9781593081386</ID>
<ID>9781593083328</ID>
<ID>9780452274426</ID>
<ID>9780060934415</ID>
<ID>9781593080556</ID>
<ID>9780375701429</ID>
<ID>9780812574920</ID>
<ID>9780451526564</ID>
<ID>9780060197353</ID>
</Root>
Nov 23 '05 #1
0 708

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

Similar topics

2
by: Aleksei Guzev | last post by:
Imagine one writing a class library CL1 for data storage. He defines classes ‘DataItem’ and ‘DataRecord’ so that the latter contains a collection of the former. And he derives class ‘IntItem’ from...
0
by: Ante Smolcic | last post by:
Hi all, I have an ArrayList that contains items of type A. I declared the XmlArrayItem atribute for that type. Now I have an derived type B (from A) also contained in the ArrayList but I get...
4
by: Wayne Wengert | last post by:
I am still stuck trying to create a Class to use for exporting and importing array data to/from XML. The format of the XML that I want to import/export is shown below as is the Class and the code I...
1
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
4
by: Jason Shohet | last post by:
We are thinking of serializing an object & passing it toseveral functions on web service. This will happen about 35 times as the page loads. The class has about 20 attributes. We're not sure...
8
by: Joe | last post by:
Hello All: Say I have a solution with two projects (Project1 and Project2) and each project contains a class (Project1 contains Class1 and Project2 contains Class2). The projects don't...
0
by: alex bean | last post by:
I am having trouble getting a class to serialize the way I want it to. I'm open to changing the class or dumping it altogether; I just need a way to produce the last set of xml. The following...
7
by: fjlaga | last post by:
I have written an Office Add-in for Excel using VB.NET and the .NET 1.1 Framework (I have Visual Studio 2003 .NET ). All works great. I want to add a User Settings/Prefereneces dialog and allow...
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: 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
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
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
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,...

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.