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.Get SqlString(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>9780486 406510</string>
<string>9780760 748718</string>
<string>9781593 081386</string>
<string>9781593 083328</string>
<string>9780452 274426</string>
<string>9780060 934415</string>
<string>9781593 080556</string>
<string>9780375 701429</string>
<string>9780812 574920</string>
<string>9780451 526564</string>
<string>9780060 197353</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>97804864065 10</ID>
<ID>97807607487 18</ID>
<ID>97815930813 86</ID>
<ID>97815930833 28</ID>
<ID>97804522744 26</ID>
<ID>97800609344 15</ID>
<ID>97815930805 56</ID>
<ID>97803757014 29</ID>
<ID>97808125749 20</ID>
<ID>97804515265 64</ID>
<ID>97800601973 53</ID>
</Root>
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.Get SqlString(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>9780486 406510</string>
<string>9780760 748718</string>
<string>9781593 081386</string>
<string>9781593 083328</string>
<string>9780452 274426</string>
<string>9780060 934415</string>
<string>9781593 080556</string>
<string>9780375 701429</string>
<string>9780812 574920</string>
<string>9780451 526564</string>
<string>9780060 197353</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>97804864065 10</ID>
<ID>97807607487 18</ID>
<ID>97815930813 86</ID>
<ID>97815930833 28</ID>
<ID>97804522744 26</ID>
<ID>97800609344 15</ID>
<ID>97815930805 56</ID>
<ID>97803757014 29</ID>
<ID>97808125749 20</ID>
<ID>97804515265 64</ID>
<ID>97800601973 53</ID>
</Root>