Defining a type that works like the types that support XmlArrayAttribute

  • Thread starter Thread starter Martin Z
  • Start date Start date
M

Martin Z

Hi,

I'm trying to support a 3rd-party XML format for which there is no
schema. As such, I've been making my objects that map to their format
using the XMLSerializer... but there's one object that stops me.

We have a class called Abstract-A, and a collection of Abstract-As
we'll call A-List. One particular subtype of AbstractA is bothering
me, because it works like this:

<AList>
<D foo="foo" bar="bar"/>
<G foo="foo">quux</G>
<B>
<B-Child foo="foo"/>
<B-Child foo="bar"/>
</B>
</AList>

As you can see, the problem is B-child. I define AList as a list of
Abstract-A's, and D, G, and B as subtypes of Abstract-A. But B is a
list of B-Childs. I tried defining B's "XmlText" member as being a
list of B-Childs, but you can only apply XmlText to strings (or arrays
of strings).

Any help would be appreciated.
 
Hi,

I'm trying to support a 3rd-party XML format for which there is no
schema. As such, I've been making my objects that map to their format
using the XMLSerializer... but there's one object that stops me.

We have a class called Abstract-A, and a collection of Abstract-As
we'll call A-List. One particular subtype of AbstractA is bothering
me, because it works like this:

<AList>
<D foo="foo" bar="bar"/>
<G foo="foo">quux</G>
<B>
<B-Child foo="foo"/>
<B-Child foo="bar"/>
</B>
</AList>

As you can see, the problem is B-child. I define AList as a list of
Abstract-A's, and D, G, and B as subtypes of Abstract-A. But B is a
list of B-Childs. I tried defining B's "XmlText" member as being a
list of B-Childs, but you can only apply XmlText to strings (or arrays
of strings).

Any help would be appreciated.

I've tried a few things more so far, still with no success:
1) XmlText, mentioned above.
2) Multiple XMLElement members (one for each element in the array -
horrible klude idea) - didn't work.
3) Implementing IEnumerable - might've worked, but the XmlSerializer
no longer considers my type B to be a subtype of Abstract-A, so it
can't be used in the AList.
 
Hi,

I'm trying to support a 3rd-party XML format for which there is no
schema. As such, I've been making my objects that map to their format
using the XMLSerializer... but there's one object that stops me.

We have a class called Abstract-A, and a collection of Abstract-As
we'll call A-List. One particular subtype of AbstractA is bothering
me, because it works like this:

<AList>
<D foo="foo" bar="bar"/>
<G foo="foo">quux</G>
<B>
<B-Child foo="foo"/>
<B-Child foo="bar"/>
</B>
</AList>

As you can see, the problem is B-child. I define AList as a list of
Abstract-A's, and D, G, and B as subtypes of Abstract-A. But B is a
list of B-Childs. I tried defining B's "XmlText" member as being a
list of B-Childs, but you can only apply XmlText to strings (or arrays
of strings).

Any help would be appreciated.

*bump*

anybody? I keep running into schema of this style - the XMLSerializer
is so limited for stuff like this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top