473,387 Members | 1,812 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.

Controlling the order of serialized elements

Okay, okay... from what I can find, I'm gonna be out of luck. I also
understand that it *shouldn't* matter but it does. I'm trying to send
some XML to Amazon and they're requiring the nodes to be in a specific
order. I am supposed to send the elements in the following
order:AmazonOrderID, MerchantOrderID, StatusCode and then a collection
of Item elements.

When I serialize my object, the XML is putting the StatusCode element
after the collection of item elements. AAAARRRGGH!!! I can't figure
out how to move the status code element ahead of the Item collection
and Amazon won't accept the feed if it's not!

Can anyone out there help me?

Here's the definition of the elements in my code:
Public AmazonOrderID As String
Public MerchantOrderID As String
<XmlElement("StatusCode")> Public Property StatusCode() As
StatusCode
Get
Return _StatusCode
End Get
Set(ByVal Value As StatusCode)
_StatusCode = Value
End Set
End Property
<XmlElement()> Public Item() As structOrderAckItem

Private _StatusCode As StatusCode
Nov 12 '05 #1
10 3611
if you convert the StatusCode to a field and not a property, what happens?
I think xml serialization is done in this order:
all public fields, in the order they are defined
all public properties, in the order they are defined

So if you have all fields or all properties, then the order the elements
appear in xml serialization is just as they have been defined in source
code. If you have a mix of fields and properties, then the order for xml
serialization is different than the order as declared in source code.

-Dino
"Mark C. Neustadt" <ma**********@gmail.com> wrote in message
news:d2**************************@posting.google.c om...
Okay, okay... from what I can find, I'm gonna be out of luck. I also
understand that it *shouldn't* matter but it does. I'm trying to send
some XML to Amazon and they're requiring the nodes to be in a specific
order. I am supposed to send the elements in the following
order:AmazonOrderID, MerchantOrderID, StatusCode and then a collection
of Item elements.

When I serialize my object, the XML is putting the StatusCode element
after the collection of item elements. AAAARRRGGH!!! I can't figure
out how to move the status code element ahead of the Item collection
and Amazon won't accept the feed if it's not!

Can anyone out there help me?

Here's the definition of the elements in my code:
Public AmazonOrderID As String
Public MerchantOrderID As String
<XmlElement("StatusCode")> Public Property StatusCode() As
StatusCode
Get
Return _StatusCode
End Get
Set(ByVal Value As StatusCode)
_StatusCode = Value
End Set
End Property
<XmlElement()> Public Item() As structOrderAckItem

Private _StatusCode As StatusCode

Nov 12 '05 #2
if you convert the StatusCode to a field and not a property, what happens?
I think xml serialization is done in this order:
all public fields, in the order they are defined
all public properties, in the order they are defined

So if you have all fields or all properties, then the order the elements
appear in xml serialization is just as they have been defined in source
code. If you have a mix of fields and properties, then the order for xml
serialization is different than the order as declared in source code.

-Dino
"Mark C. Neustadt" <ma**********@gmail.com> wrote in message
news:d2**************************@posting.google.c om...
Okay, okay... from what I can find, I'm gonna be out of luck. I also
understand that it *shouldn't* matter but it does. I'm trying to send
some XML to Amazon and they're requiring the nodes to be in a specific
order. I am supposed to send the elements in the following
order:AmazonOrderID, MerchantOrderID, StatusCode and then a collection
of Item elements.

When I serialize my object, the XML is putting the StatusCode element
after the collection of item elements. AAAARRRGGH!!! I can't figure
out how to move the status code element ahead of the Item collection
and Amazon won't accept the feed if it's not!

Can anyone out there help me?

Here's the definition of the elements in my code:
Public AmazonOrderID As String
Public MerchantOrderID As String
<XmlElement("StatusCode")> Public Property StatusCode() As
StatusCode
Get
Return _StatusCode
End Get
Set(ByVal Value As StatusCode)
_StatusCode = Value
End Set
End Property
<XmlElement()> Public Item() As structOrderAckItem

Private _StatusCode As StatusCode

Nov 12 '05 #3
BINGO BABY! Thanks 10^6!!

I initially had the thing setup as a property so that I could use an
enumeration to get the value out the way I needed it. I found that by
changing it to a defined type and then putting <XMLEnum()> before the
enumerated values, it works perfectly.

I hope this little code snippet helps people out. Working with Amazon
has been very difficult. My code now looks like this:

<Serializable(), XmlRoot("OrderAcknowledgement")> _
Public Class OrderAcknowledgement
Public AmazonOrderID As String
Public MerchantOrderID As String
Public StatusCode As StatusCodes
<XmlElement()> Public Item() As structOrderAckItem
End Class

Public Enum StatusCodes As Integer
<XmlEnum()> Success = 0
<XmlEnum()> Failure
End Enum

Public Structure structOrderAckItem
Public AmazonOrderItemCode As String
Public MerchantOrderItemID As String
End Structure
------------------------------
Mark C. Neustadt, MCSD
Full Compass Systems, LTD.
00**************@gmail.com_000
(remove the first four and last four characters from the e-mail address)
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4
BINGO BABY! Thanks 10^6!!

I initially had the thing setup as a property so that I could use an
enumeration to get the value out the way I needed it. I found that by
changing it to a defined type and then putting <XMLEnum()> before the
enumerated values, it works perfectly.

I hope this little code snippet helps people out. Working with Amazon
has been very difficult. My code now looks like this:

<Serializable(), XmlRoot("OrderAcknowledgement")> _
Public Class OrderAcknowledgement
Public AmazonOrderID As String
Public MerchantOrderID As String
Public StatusCode As StatusCodes
<XmlElement()> Public Item() As structOrderAckItem
End Class

Public Enum StatusCodes As Integer
<XmlEnum()> Success = 0
<XmlEnum()> Failure
End Enum

Public Structure structOrderAckItem
Public AmazonOrderItemCode As String
Public MerchantOrderItemID As String
End Structure
------------------------------
Mark C. Neustadt, MCSD
Full Compass Systems, LTD.
00**************@gmail.com_000
(remove the first four and last four characters from the e-mail address)
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #5
you should blog this. (do you have one? )

"Mark Neustadt" <ma**********@gmail.com> wrote in message
news:ee**************@TK2MSFTNGP12.phx.gbl...
BINGO BABY! Thanks 10^6!!

I initially had the thing setup as a property so that I could use an
enumeration to get the value out the way I needed it. I found that by
changing it to a defined type and then putting <XMLEnum()> before the
enumerated values, it works perfectly.

I hope this little code snippet helps people out. Working with Amazon
has been very difficult. My code now looks like this:

<Serializable(), XmlRoot("OrderAcknowledgement")> _
Public Class OrderAcknowledgement
Public AmazonOrderID As String
Public MerchantOrderID As String
Public StatusCode As StatusCodes
<XmlElement()> Public Item() As structOrderAckItem
End Class

Public Enum StatusCodes As Integer
<XmlEnum()> Success = 0
<XmlEnum()> Failure
End Enum

Public Structure structOrderAckItem
Public AmazonOrderItemCode As String
Public MerchantOrderItemID As String
End Structure
------------------------------
Mark C. Neustadt, MCSD
Full Compass Systems, LTD.
000_ma**********@gmail.com_000
(remove the first four and last four characters from the e-mail address)
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #6
you should blog this. (do you have one? )

"Mark Neustadt" <ma**********@gmail.com> wrote in message
news:ee**************@TK2MSFTNGP12.phx.gbl...
BINGO BABY! Thanks 10^6!!

I initially had the thing setup as a property so that I could use an
enumeration to get the value out the way I needed it. I found that by
changing it to a defined type and then putting <XMLEnum()> before the
enumerated values, it works perfectly.

I hope this little code snippet helps people out. Working with Amazon
has been very difficult. My code now looks like this:

<Serializable(), XmlRoot("OrderAcknowledgement")> _
Public Class OrderAcknowledgement
Public AmazonOrderID As String
Public MerchantOrderID As String
Public StatusCode As StatusCodes
<XmlElement()> Public Item() As structOrderAckItem
End Class

Public Enum StatusCodes As Integer
<XmlEnum()> Success = 0
<XmlEnum()> Failure
End Enum

Public Structure structOrderAckItem
Public AmazonOrderItemCode As String
Public MerchantOrderItemID As String
End Structure
------------------------------
Mark C. Neustadt, MCSD
Full Compass Systems, LTD.
000_ma**********@gmail.com_000
(remove the first four and last four characters from the e-mail address)
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #7

That's a good idea. I do have a blog but it wouldn't really be right
for this kind of post. I created a new blog.

http://markstechnoblog.blogspot.com/

Thanks a million (again) for your help. I gave you credit in my blog
post about this issue and also referred to you as a good friend. I hope
you're okay with that. :-)

MCN

------------------------------
Mark C. Neustadt, MCSD
Full Compass Systems, LTD.
00**************@gmail.com_000
(remove the first four and last four characters from the e-mail address)
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #8

That's a good idea. I do have a blog but it wouldn't really be right
for this kind of post. I created a new blog.

http://markstechnoblog.blogspot.com/

Thanks a million (again) for your help. I gave you credit in my blog
post about this issue and also referred to you as a good friend. I hope
you're okay with that. :-)

MCN

------------------------------
Mark C. Neustadt, MCSD
Full Compass Systems, LTD.
00**************@gmail.com_000
(remove the first four and last four characters from the e-mail address)
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #9
you betcha.
one can never have too many friends!
:)

"Mark Neustadt" <ma**********@gmail.com> wrote in message
news:uA**************@TK2MSFTNGP11.phx.gbl...

That's a good idea. I do have a blog but it wouldn't really be right
for this kind of post. I created a new blog.

http://markstechnoblog.blogspot.com/

Thanks a million (again) for your help. I gave you credit in my blog
post about this issue and also referred to you as a good friend. I hope
you're okay with that. :-)

MCN

------------------------------
Mark C. Neustadt, MCSD
Full Compass Systems, LTD.
000_ma**********@gmail.com_000
(remove the first four and last four characters from the e-mail address)
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #10
you betcha.
one can never have too many friends!
:)

"Mark Neustadt" <ma**********@gmail.com> wrote in message
news:uA**************@TK2MSFTNGP11.phx.gbl...

That's a good idea. I do have a blog but it wouldn't really be right
for this kind of post. I created a new blog.

http://markstechnoblog.blogspot.com/

Thanks a million (again) for your help. I gave you credit in my blog
post about this issue and also referred to you as a good friend. I hope
you're okay with that. :-)

MCN

------------------------------
Mark C. Neustadt, MCSD
Full Compass Systems, LTD.
000_ma**********@gmail.com_000
(remove the first four and last four characters from the e-mail address)
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #11

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

Similar topics

7
by: Marcio Rosa da Silva | last post by:
Hi! In dictionaries, unlinke lists, it doesn't matter the order one inserts the contents, elements are stored using its own rules. Ex: >>> d = {3: 4, 1: 2} >>> d {1: 2, 3: 4}
4
by: Christine McGavran | last post by:
To continue a previous thread, sort of... I have defined a schema for describing a windows-style user interface. My application correctly parses and uses that schema. I'm now trying to get that...
1
by: Daniel Lidström | last post by:
Hello, how can I control the order of which elements are serialized. For example, my class looks like: public __gc class Author { public: Author(); // get/set methods
0
by: Mark C. Neustadt | last post by:
Okay, okay... from what I can find, I'm gonna be out of luck. I also understand that it *shouldn't* matter but it does. I'm trying to send some XML to Amazon and they're requiring the nodes to be...
1
by: rkc | last post by:
Is it safe to assume that the elements in the resulting array will always appear in the same order that they appear in the original string?
2
by: Jerry LeVan | last post by:
I have an srf sql function "annual_report(<year>)" that as 14 columns, a category, 12 month numeric columns, and a total numeric column. The function finds monthly totals for each category...
7
by: paul.rusu | last post by:
I have a element "v" wich has different types of objects a,b,c. and i do: for $x in $doc/v/a where ... return $x for $x in $doc/v/b where ... return $x for $x in $doc/v/c where ... return $x...
2
by: Bardo | last post by:
Hi all, I am a newbie to using the XML Schema Object Model (SOM) and would like a few pointers on how to perform a particular task. I am essentially trying to search for elements/attributes via...
2
by: libsfan01 | last post by:
hi all im looking for help on how you can track the order of elements in a parent div when these elements are dragable (with scriptaculous)? I tihnk i need to write a function that is called...
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
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,...
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.