c# - XmlSerializer and XmlArrayItem -


the xml looks following:

<publisher sequence="1" primaryindicator="yes">   <publisherid idtype="shortname">ysc</publisherid>   <publisherid idtype="xy" encrypted="vlsc1v9k23leo1baok6nxxrozapksany" library="http://xys.abc.com">21503</publisherid>   <publishername nametype="legal">xys legal name</publishername> </publisher> 

and class mapped as:

type publisherid() =      [<defaultvalue>] val mutable _idtype: string ;     [<defaultvalue>] val mutable _encrypted: string ;     [<defaultvalue>] val mutable _library: string ;     [<defaultvalue>] val mutable _value: string ;      [<xmlattribute>] member this.idtype get() = this._idtype , set(v) = this._idtype <- v     [<xmlattribute>] member this.encrypted get() = this._encrypted , set(v) = this._encrypted <- v     [<xmlattribute>] member this.library get() = this._library , set(v) = this._library <- v     [<xmltextattribute>] member this.value get() = this._value , set(v) = this._value <- v  type publisher() =      [<defaultvalue>] val mutable _sequence : int     [<defaultvalue>] val mutable _primaryindicator: string ;     [<defaultvalue>] val mutable _publisherids : list<publisherid>             this._publisherids <- new list<publisherid>();       [<xmlattribute>] member this.sequence get() = this._sequence , set(v) = this._sequence <- v     [<xmlattribute>] member this.primaryindicator get() = this._primaryindicator , set(v) = this._primaryindicator <- v      [<xmlarrayattribute>]     [<xmlarrayitem(typeof<publisherid>, elementname = "publisherid")>]     member this.publisherid get() = this._publisherids , set(v) = this._publisherids <- v 

and modified member attributes on elemetn in question:

    [<xmlarrayitem(typeof<publisherid>, elementname = "publisherid")>]     member this.publisherid get() = this._publisherids , set(v) = this._publisherids <- v 

the problem that, not populating _publisherids fields. tried switching array , didn't either. breakpoint in setter never gets hit, thinking there wrong annotations.

i have had success structures like:

<publisher sequence="1" primaryindicator="yes">   <publisherids>      <publisherid idtype="shortname">ysc</publisherid>      <publisherid idtype="xy" encrypted="vlsc1v9k23leo1baok6nxxrozapksany" library="http://xys.abc.com">21503</publisherid>    </publisherids>   <publishername nametype="legal">xys legal name</publishername> </publisher> 

using similar attributes (albeit in c#), changing xml structure not ann option - comming vendor.

note: tagging c# group may able annotations. please remove appologies, if inappropriate tag.

thank you

found answer here:

using xmlarrayitem attribute without xmlarray on serializable c# class

for following along @ home:

[<xmlelement>] member this.publisherid get() = this._publisherids , set(v) = this._publisherids <- v  

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -