F
FredZimmerman
Its reversing order of attributes (XmlElements) set in Serializer
class.
namespace Windstream.Business
{
[Serializable]
public class Order
{
public Windstream.Business.Broadband Broadband;
public Windstream.Business.POTS POTS;
public Order()
{
// Default Constructor.
}
// Order
private string orderrequestid;
public string OrderRequestId
{
get { return orderrequestid; }
set { orderrequestid = value; }
}
// CODE that instantiates Order, and calls XMLSerializer() .
Order _order = new Order();
_order.OrderRequestId = Session["OrderRequestId"].ToString();
_order.Broadband = new Broadband();
bbLineItem = new LineItem();
bbLineItem.ProductId =
int.Parse(hashBroadbandSpeed["ProductId"].ToString());
// ...
// ...
_order.Broadband.LineItems.LineItem = arrBBOrderItems;
bool bXml = XmlSerialize.ToXmlFile(_order);
public static class XmlSerialize
{
public static bool ToXmlFile(Object objToXml)
{
// XmlTextWriter xtw = new XtmTextWriter();
try
{
String _xmlFile;
_xmlFile = XmlFilePath();
StreamWriter strWriter = new StreamWriter(_xmlFile);
XmlSerializer xmlSerializer = new
XmlSerializer(typeof(Windstream.Business.Order));
xmlSerializer.Serialize(strWriter, objToXml);
}
}
OUTPUT:
<Order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Broadband>
<LineItems>
<LineItem>
<Quantity />
<ItemName>Broadband 6 Mbps</ItemName>
<ProductId>112</ProductId>
<Price>29.99</Price>
<Description>Download Max. Speed of 6.0 Mbps, Upload Max Speed
of 384 Kbps. This pricing available for new customers only when
bundled with qualifying services.</Description>
<FixedRecurringPrice>R</FixedRecurringPrice>
</LineItem>
</LineItems>
</Broadband>
<OrderRequestId>1</OrderRequestId>
</Order>
class.
namespace Windstream.Business
{
[Serializable]
public class Order
{
public Windstream.Business.Broadband Broadband;
public Windstream.Business.POTS POTS;
public Order()
{
// Default Constructor.
}
// Order
private string orderrequestid;
public string OrderRequestId
{
get { return orderrequestid; }
set { orderrequestid = value; }
}
// CODE that instantiates Order, and calls XMLSerializer() .
Order _order = new Order();
_order.OrderRequestId = Session["OrderRequestId"].ToString();
_order.Broadband = new Broadband();
bbLineItem = new LineItem();
bbLineItem.ProductId =
int.Parse(hashBroadbandSpeed["ProductId"].ToString());
// ...
// ...
_order.Broadband.LineItems.LineItem = arrBBOrderItems;
bool bXml = XmlSerialize.ToXmlFile(_order);
public static class XmlSerialize
{
public static bool ToXmlFile(Object objToXml)
{
// XmlTextWriter xtw = new XtmTextWriter();
try
{
String _xmlFile;
_xmlFile = XmlFilePath();
StreamWriter strWriter = new StreamWriter(_xmlFile);
XmlSerializer xmlSerializer = new
XmlSerializer(typeof(Windstream.Business.Order));
xmlSerializer.Serialize(strWriter, objToXml);
}
}
OUTPUT:
<Order xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Broadband>
<LineItems>
<LineItem>
<Quantity />
<ItemName>Broadband 6 Mbps</ItemName>
<ProductId>112</ProductId>
<Price>29.99</Price>
<Description>Download Max. Speed of 6.0 Mbps, Upload Max Speed
of 384 Kbps. This pricing available for new customers only when
bundled with qualifying services.</Description>
<FixedRecurringPrice>R</FixedRecurringPrice>
</LineItem>
</LineItems>
</Broadband>
<OrderRequestId>1</OrderRequestId>
</Order>