470,815 Members | 1,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

how to deserialize variable element/node

I've a complex problem:

I'm deserializing a very long string of XML into a very large object
foo:

<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>

or sometimes it's

<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>

the foo class is either foo1

class foo {
....
string bar;
....
}

or foo2

class foo {
...
string bar[];
...
}

class bar {
string zip;
string zap;
string zoo;
}

The short bar element is the only difference between the large foo1 and
foo2.

What is the best (ok, easiest; robust; fastest) way to do this?
1. select the correct type
2. remove the <bar>...</barfrom the string and deserialize separately
3. use XMLAnyElement
4. use the unknown element event

Thanks,

Bill

Nov 16 '06 #1
11 2646

wp*********@gmail.com wrote:
I've a complex problem:
Said a different way: i need an element that can be either a
complexType or a string
I'm deserializing a very long string of XML into a very large object
foo:

<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>

or sometimes it's

<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>

the foo class is either foo1

class foo {
...
string bar;
...
}

or foo2

class foo {
...
string bar[];
...
}

class bar {
string zip;
string zap;
string zoo;
}

The short bar element is the only difference between the large foo1 and
foo2.

What is the best (ok, easiest; robust; fastest) way to do this?
1. select the correct type
2. remove the <bar>...</barfrom the string and deserialize separately
3. use XMLAnyElement
4. use the unknown element event

Thanks,

Bill
Nov 16 '06 #2
On 15 Nov 2006 19:28:42 -0800, wp*********@gmail.com wrote:
I've a complex problem:

I'm deserializing a very long string of XML into a very large object
foo:

<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>

or sometimes it's

<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>

the foo class is either foo1

class foo {
...
string bar;
...
}

or foo2

class foo {
...
string bar[];
...
}

class bar {
string zip;
string zap;
string zoo;
}

The short bar element is the only difference between the large foo1 and
foo2.

What is the best (ok, easiest; robust; fastest) way to do this?
1. select the correct type
2. remove the <bar>...</barfrom the string and deserialize separately
3. use XMLAnyElement
4. use the unknown element event

Thanks,

Bill
Well, this code doesn't quite make sense. Is bar a variable name or a
class? 'string bar' is a string called bar, 'string bar[]' is an array of
strings called bar, but then you've got a class called bar :)
In .NET as far as I know there is no native way to have an XMLAnyElement
stored in your XML, as it will always be escaped and stored as a string.
If you *must* store 'raw' XML then you have to implement the ISerializable
interface and perform your own XML stream read/write, and I do this in our
product to store and retrieve XML marked-up freeform text (containing
nested <Band <Itags etc.). It's messy, and should be avoided if
possible.
One problem in your description is that you give two definitions for foo. A
class can be one or the other, but both can't exist unless they have
different names, in which case your tags will be different so you will know
the class type needed to recreate them.
Remember that you don't have to use the built in serializers; you can write
your own using XMLWriters and readers.

Cheers,
Gadget
Nov 16 '06 #3

Gadget wrote:
On 15 Nov 2006 19:28:42 -0800, wp*********@gmail.com wrote:
I've a complex problem:

I'm deserializing a very long string of XML into a very large object
foo:

<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>

or sometimes it's

<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>

the foo class is either foo1

class foo {
...
string bar;
...
}

or foo2

class foo {
...
string bar[];
...
}

class bar {
string zip;
string zap;
string zoo;
}

The short bar element is the only difference between the large foo1 and
foo2.

What is the best (ok, easiest; robust; fastest) way to do this?
1. select the correct type
2. remove the <bar>...</barfrom the string and deserialize separately
3. use XMLAnyElement
4. use the unknown element event

Thanks,

Bill

Well, this code doesn't quite make sense. Is bar a variable name or a
class? 'string bar' is a string called bar, 'string bar[]' is an array of
strings called bar, but then you've got a class called bar :)
In .NET as far as I know there is no native way to have an XMLAnyElement
stored in your XML, as it will always be escaped and stored as a string.
If you *must* store 'raw' XML then you have to implement the ISerializable
interface and perform your own XML stream read/write, and I do this in our
product to store and retrieve XML marked-up freeform text (containing
nested <Band <Itags etc.). It's messy, and should be avoided if
possible.
One problem in your description is that you give two definitions for foo. A
class can be one or the other, but both can't exist unless they have
different names, in which case your tags will be different so you will know
the class type needed to recreate them.
Remember that you don't have to use the built in serializers; you can write
your own using XMLWriters and readers.

Cheers,
Gadget
I should not have started of with "I've a complex problem"; it's really
rather simple. The solution, however, may involve some complexity.

Anyway, I have a single class called foo. Into it, I want to
deserialize XML for a schema which I do not control. The XML will
sometimes have an element bar which is a string, and sometimes it will
be complex data.

<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>

OR

(corrected)

class foo {
...
bar baz[];
...
}

class bar {
string zip;
string zap;
string zoo;
}

Thanks for the reply :)

Nov 16 '06 #4

wp*********@gmail.com wrote:
Gadget wrote:
On 15 Nov 2006 19:28:42 -0800, wp*********@gmail.com wrote:
I've a complex problem:
I need to re-explain this ...

Whether I deserialize this:
>
<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>
>
Or this:
>
<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>
>
I want to end up with an object

class foo {
string bar;
baz[] Baz;
}

class {
string zip;
string zap;
string zoo;
}

In the first deserialization case, bar = "sometimes a simple string is
here" and Baz is null. In the second bar is null and zip, zap and zoo
are filled in.

Thanks

Nov 17 '06 #5
On 16 Nov 2006 19:54:06 -0800, wp*********@gmail.com wrote:
wp*********@gmail.com wrote:
>Gadget wrote:
>>On 15 Nov 2006 19:28:42 -0800, wp*********@gmail.com wrote:

I've a complex problem:

I need to re-explain this ...

Whether I deserialize this:
>>
<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>

Or this:
>>
<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>

I want to end up with an object

class foo {
string bar;
baz[] Baz;
}

class {
string zip;
string zap;
string zoo;
}

In the first deserialization case, bar = "sometimes a simple string is
here" and Baz is null. In the second bar is null and zip, zap and zoo
are filled in.

Thanks
OK, so I think you're either misunderstanding XML or trying to use it in an
unorthadox and incorrect manner.
Your two XML fragments would have to be represented in an XML schema by
specifying mixed content, as in one case <barcontains TEXT and in the
other it contains a set of tags.
Why do you feel the need to read this structure of data? Do you have an
existing data set with this format strings, or are you responsible for
creating the XML?
Your comment that your problem is 'rather simple' is not true. Perhaps your
requirements are, but you seem to have created a very awkward problem for
yourself.
In XML your zip/zap/zoo should be inside a pair of <baztags, so you
should have either of the following:
<foo>
<bar />
</baz>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</baz>
</foo>

<foo>
<bar>sometimes a simple string is here</bar>
<baz />
</foo>

This means you use the same class for 'foo'. In the first example there is
no string in bar and in second case there is no object assigned to baz
(it's null).
When the deserializer looks at the XML it sees <bar>, reads that it has no
content, and sets it to be empty.
Next, it sees the tag <baz>, creates an instance of a baz, and reads the
content tags, assigning each value to a property in the baz object via the
reflection detected properties.
If baz is an empty tag then the object is set to null.

This weird mixing of meanings in XML produce ambiguity that the built-in
serializer/deserializer can not resolve and won't even try to.

Cheers,
Gadget
Nov 17 '06 #6

Gadget wrote:
On 16 Nov 2006 19:54:06 -0800, wp*********@gmail.com wrote:
wp*********@gmail.com wrote:
Gadget wrote:
On 15 Nov 2006 19:28:42 -0800, wp*********@gmail.com wrote:

I've a complex problem:
I need to re-explain this ...

Whether I deserialize this:
>
<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>
Or this:
>
<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>
I want to end up with an object

class foo {
string bar;
baz[] Baz;
}

class {
string zip;
string zap;
string zoo;
}

In the first deserialization case, bar = "sometimes a simple string is
here" and Baz is null. In the second bar is null and zip, zap and zoo
are filled in.

Thanks

OK, so I think you're either misunderstanding XML or trying to use it in an
unorthadox and incorrect manner.
Your two XML fragments would have to be represented in an XML schema by
specifying mixed content, as in one case <barcontains TEXT and in the
other it contains a set of tags.
Why do you feel the need to read this structure of data? Do you have an
existing data set with this format strings, or are you responsible for
creating the XML?
Your comment that your problem is 'rather simple' is not true. Perhaps your
requirements are, but you seem to have created a very awkward problem for
yourself.
In XML your zip/zap/zoo should be inside a pair of <baztags, so you
should have either of the following:
<foo>
<bar />
</baz>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</baz>
</foo>

<foo>
<bar>sometimes a simple string is here</bar>
<baz />
</foo>

This means you use the same class for 'foo'. In the first example there is
no string in bar and in second case there is no object assigned to baz
(it's null).
When the deserializer looks at the XML it sees <bar>, reads that it has no
content, and sets it to be empty.
Next, it sees the tag <baz>, creates an instance of a baz, and reads the
content tags, assigning each value to a property in the baz object via the
reflection detected properties.
If baz is an empty tag then the object is set to null.

This weird mixing of meanings in XML produce ambiguity that the built-in
serializer/deserializer can not resolve and won't even try to.

Cheers,
Gadget
I have an existing data set with this format and I have no control of
it. The people that have forced it on me (and others who need to
interface to their system) seem not to have a very good understanding
and/or are using it in some unorthodox manner; perhaps in order to
discourage deserialization?

So ... any ideas?

Nov 18 '06 #7
On 17 Nov 2006 20:48:34 -0800, wp*********@gmail.com wrote:
Gadget wrote:
>On 16 Nov 2006 19:54:06 -0800, wp*********@gmail.com wrote:
>>wp*********@gmail.com wrote:
Gadget wrote:
On 15 Nov 2006 19:28:42 -0800, wp*********@gmail.com wrote:
>
I've a complex problem:

I need to re-explain this ...

Whether I deserialize this:

<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>
Or this:

<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>
I want to end up with an object

class foo {
string bar;
baz[] Baz;
}

class {
string zip;
string zap;
string zoo;
}

In the first deserialization case, bar = "sometimes a simple string is
here" and Baz is null. In the second bar is null and zip, zap and zoo
are filled in.

Thanks

OK, so I think you're either misunderstanding XML or trying to use it in an
unorthadox and incorrect manner.
Your two XML fragments would have to be represented in an XML schema by
specifying mixed content, as in one case <barcontains TEXT and in the
other it contains a set of tags.
Why do you feel the need to read this structure of data? Do you have an
existing data set with this format strings, or are you responsible for
creating the XML?
Your comment that your problem is 'rather simple' is not true. Perhaps your
requirements are, but you seem to have created a very awkward problem for
yourself.
In XML your zip/zap/zoo should be inside a pair of <baztags, so you
should have either of the following:
<foo>
<bar />
</baz>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</baz>
</foo>

<foo>
<bar>sometimes a simple string is here</bar>
<baz />
</foo>

This means you use the same class for 'foo'. In the first example there is
no string in bar and in second case there is no object assigned to baz
(it's null).
When the deserializer looks at the XML it sees <bar>, reads that it has no
content, and sets it to be empty.
Next, it sees the tag <baz>, creates an instance of a baz, and reads the
content tags, assigning each value to a property in the baz object via the
reflection detected properties.
If baz is an empty tag then the object is set to null.

This weird mixing of meanings in XML produce ambiguity that the built-in
serializer/deserializer can not resolve and won't even try to.

Cheers,
Gadget

I have an existing data set with this format and I have no control of
it. The people that have forced it on me (and others who need to
interface to their system) seem not to have a very good understanding
and/or are using it in some unorthodox manner; perhaps in order to
discourage deserialization?

So ... any ideas?
Yes, forget about serialization. You've been describing the classes you
want to serialize/deserialize, but in fact you don't have the classes, you
only have the dataset.
A better way of asking for a solution is to say
"I have a set of XML of the following format. What would be the easiest way
of reading/writing this to an object". Asking it by telling us the classes
you've decided on is really muddying the water.

I find it difficult to believe any company with XML know-how would provide
you with XML in both of formats you describe:

<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>

OR

<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>

This is a very bizarre way for them to serialize data, so can I suggest you
post two samples of the *actual* data so we can see the real structure?

Cheers,
Gadget
Nov 19 '06 #8

Gadget wrote:
On 17 Nov 2006 20:48:34 -0800, wp*********@gmail.com wrote:
Gadget wrote:
On 16 Nov 2006 19:54:06 -0800, wp*********@gmail.com wrote:

wp*********@gmail.com wrote:
Gadget wrote:
On 15 Nov 2006 19:28:42 -0800, wp*********@gmail.com wrote:

I've a complex problem:

I need to re-explain this ...

Whether I deserialize this:

<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>
Or this:

<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>
I want to end up with an object

class foo {
string bar;
baz[] Baz;
}

class {
string zip;
string zap;
string zoo;
}

In the first deserialization case, bar = "sometimes a simple string is
here" and Baz is null. In the second bar is null and zip, zap and zoo
are filled in.

Thanks

OK, so I think you're either misunderstanding XML or trying to use it in an
unorthadox and incorrect manner.
Your two XML fragments would have to be represented in an XML schema by
specifying mixed content, as in one case <barcontains TEXT and in the
other it contains a set of tags.
Why do you feel the need to read this structure of data? Do you have an
existing data set with this format strings, or are you responsible for
creating the XML?
Your comment that your problem is 'rather simple' is not true. Perhaps your
requirements are, but you seem to have created a very awkward problem for
yourself.
In XML your zip/zap/zoo should be inside a pair of <baztags, so you
should have either of the following:
<foo>
<bar />
</baz>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</baz>
</foo>

<foo>
<bar>sometimes a simple string is here</bar>
<baz />
</foo>

This means you use the same class for 'foo'. In the first example there is
no string in bar and in second case there is no object assigned to baz
(it's null).
When the deserializer looks at the XML it sees <bar>, reads that it has no
content, and sets it to be empty.
Next, it sees the tag <baz>, creates an instance of a baz, and reads the
content tags, assigning each value to a property in the baz object via the
reflection detected properties.
If baz is an empty tag then the object is set to null.

This weird mixing of meanings in XML produce ambiguity that the built-in
serializer/deserializer can not resolve and won't even try to.

Cheers,
Gadget
I have an existing data set with this format and I have no control of
it. The people that have forced it on me (and others who need to
interface to their system) seem not to have a very good understanding
and/or are using it in some unorthodox manner; perhaps in order to
discourage deserialization?

So ... any ideas?

Yes, forget about serialization. You've been describing the classes you
want to serialize/deserialize, but in fact you don't have the classes, you
only have the dataset.
A better way of asking for a solution is to say
"I have a set of XML of the following format. What would be the easiest way
of reading/writing this to an object". Asking it by telling us the classes
you've decided on is really muddying the water.

I find it difficult to believe any company with XML know-how would provide
you with XML in both of formats you describe:

<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>

OR

<foo>
.......
<bar>
<zip>sometimes</zip>
<zap>more structure</zap>
<zoo>is here</zoo>
</bar>
.......
</foo>

This is a very bizarre way for them to serialize data, so can I suggest you
post two samples of the *actual* data so we can see the real structure?

Cheers,
Gadget
Again, the issue is DESERIALIZATION, not serialization.

This is from their spec. The issue is the <message_stringnode; it
will either be a simple string or complex. I can deserialize this but
only if I do so into the correct object.

<?xml version="1.0"?>
<tms_msg
xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<trans_id>String(38)</trans_ID>
<veh_fleet_code>String(4)</veh_fleet_code>
<veh_radio_code>String(10)</veh_radio_code>
<protocol_version>String(2)</protocol_version>
<packet_code>String(3)</packet_code>
<transaction>
<trans_date_time>DateTime (yyyy-mm-ddThh:nn:ss)</trans_date_time>
<date_time_offset>Integer(4)</date_time_offset>
<tkt_code>String(12)</tkt_code>
<order_code>String(50)</order_code>
<tkt_date_time>DateTime (yyyy-mm-ddThh:nn:ss)</tkt_date_time>
<truck_code>String(10)</truck_code>
<employee_code>String(12)</employee_code>
<message_string>String (5000)</message_string>
<message>String (5000)</message>
<trans_cat>String(4)</trans_cat>
<trans_type>String(3)</trans_type>
<trans_sub_type>String(3)</trans_sub_type>
<trans_origin>String(3)</trans_origin>
<trans_origin_IPAddr>String(15)</trans_origin_IPAddr>
<trans_origin_machname>String(32)</trans_origin_machname>
<trans_origin_username>String(25)</trans_origin_username>
<time_to_live>Integer(4)</time_to_live>
</transaction>
</tms_msg>

Nov 20 '06 #9
<wp*********@gmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
>
....
Again, the issue is DESERIALIZATION, not serialization.

This is from their spec. The issue is the <message_stringnode; it
will either be a simple string or complex. I can deserialize this but
only if I do so into the correct object.

<?xml version="1.0"?>
<tms_msg
xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<trans_id>String(38)</trans_ID>
<veh_fleet_code>String(4)</veh_fleet_code>
<veh_radio_code>String(10)</veh_radio_code>
<protocol_version>String(2)</protocol_version>
<packet_code>String(3)</packet_code>
<transaction>
<trans_date_time>DateTime (yyyy-mm-ddThh:nn:ss)</trans_date_time>
<date_time_offset>Integer(4)</date_time_offset>
<tkt_code>String(12)</tkt_code>
<order_code>String(50)</order_code>
<tkt_date_time>DateTime (yyyy-mm-ddThh:nn:ss)</tkt_date_time>
<truck_code>String(10)</truck_code>
<employee_code>String(12)</employee_code>
<message_string>String (5000)</message_string>
<message>String (5000)</message>
<trans_cat>String(4)</trans_cat>
<trans_type>String(3)</trans_type>
<trans_sub_type>String(3)</trans_sub_type>
<trans_origin>String(3)</trans_origin>
<trans_origin_IPAddr>String(15)</trans_origin_IPAddr>
<trans_origin_machname>String(32)</trans_origin_machname>
<trans_origin_username>String(25)</trans_origin_username>
<time_to_live>Integer(4)</time_to_live>
</transaction>
</tms_msg>
As another poster mentioned, this is clearly an organization which does not
understand XML. They should have sent you a schema instead of this pseudo
instance document.

Ask them if they have any example code (in any language) for serializing and
deserializing this format. Also, ask them if they have an actual schema, as
they at least seem to know the correct namespace for that.

John
Nov 21 '06 #10
John Saunders wrote:
<wp*********@gmail.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
...
Again, the issue is DESERIALIZATION, not serialization.

This is from their spec. The issue is the <message_stringnode; it
will either be a simple string or complex. I can deserialize this but
only if I do so into the correct object.

<?xml version="1.0"?>
<tms_msg
xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<trans_id>String(38)</trans_ID>
<veh_fleet_code>String(4)</veh_fleet_code>
<veh_radio_code>String(10)</veh_radio_code>
<protocol_version>String(2)</protocol_version>
<packet_code>String(3)</packet_code>
<transaction>
<trans_date_time>DateTime (yyyy-mm-ddThh:nn:ss)</trans_date_time>
<date_time_offset>Integer(4)</date_time_offset>
<tkt_code>String(12)</tkt_code>
<order_code>String(50)</order_code>
<tkt_date_time>DateTime (yyyy-mm-ddThh:nn:ss)</tkt_date_time>
<truck_code>String(10)</truck_code>
<employee_code>String(12)</employee_code>
<message_string>String (5000)</message_string>
<message>String (5000)</message>
<trans_cat>String(4)</trans_cat>
<trans_type>String(3)</trans_type>
<trans_sub_type>String(3)</trans_sub_type>
<trans_origin>String(3)</trans_origin>
<trans_origin_IPAddr>String(15)</trans_origin_IPAddr>
<trans_origin_machname>String(32)</trans_origin_machname>
<trans_origin_username>String(25)</trans_origin_username>
<time_to_live>Integer(4)</time_to_live>
</transaction>
</tms_msg>

As another poster mentioned, this is clearly an organization which does not
understand XML. They should have sent you a schema instead of this pseudo
instance document.

Ask them if they have any example code (in any language) for serializing and
deserializing this format. Also, ask them if they have an actual schema, as
they at least seem to know the correct namespace for that.

John
Thanks John.

Regardless of what or how much they understand or what they could or
should provide, it is what it is; I seem to have no choice but to work
with this as is and with what they have provided.

There is either a way to directly deserialize this (the variable
message_string tag) or there is not. One option that I'm seriously
considering is to remove the <message_stringcontents before I
deserialize and process it seperately.

Thanks,

Bill

Nov 22 '06 #11
OK, ignoring the fact that (as John pointed out) this is a dreadful way to
'document' the format of the data...

Firstly, it makes no difference whether you are trying to serialize or
deserialize. Exactly the same problems occurr with XML data structures.

Secondly, assuming you do receive data in this format then the contents of
that string *cannot* be complex XML. They may indeed have some of their own
'markup' in that section, but it does not make up part of the tms_msg
packet, and can be classed as its own subset of XML data.

For example, if they want to give you a message
"An apalling document"
then they will provide:
:
<employee_code>12345</employee_code>
<message_string>An apalling document</message_string>
<message>And this is another message thing</message>
:

If however they decide to have 'markup' in there and return
"An <B>apalling</Bdocument"
then they will provide
:
<employee_code>12345</employee_code>
<message_string>An &lt;B&gt;apalling&lt;/B&gt; document</message_string>
<message>And this is another message thing</message>
:

This is the rule of XML. If you are placing a string (as they say,
string(5000)) in your document then they *must* escape the codes.
This is not a problem for you, and .NET handles this all automatically.
I've appended a pair of classes below that should serialize and deserialize
to their format of data.

If you like you can post an *actual sample* of their data to confirm what
I'm interpretting from their document.

Cheers,
Gadget
[Serializable]
public class tms_msg
{
private string _trans_id;

public string trans_id
{
get { return _trans_id; }
set { _trans_id = value; }
}
private string _veh_fleet_code;

public string veh_fleet_code
{
get { return _veh_fleet_code; }
set { _veh_fleet_code = value; }
}
private string _veh_radio_code;

public string veh_radio_code
{
get { return _veh_radio_code; }
set { _veh_radio_code = value; }
}
private string _protocol_version;

public string protocol_version
{
get { return _protocol_version; }
set { _protocol_version = value; }
}
private string _packet_code;

public string packet_code
{
get { return _packet_code; }
set { _packet_code = value; }
}
private transaction _subTransaction;

public transaction subTransaction
{
get { return _subTransaction; }
set { _subTransaction = value; }
}
}

public class transaction
{
private DateTime _trans_date_time;
public DateTime trans_date_time
{
get { return _trans_date_time; }
set { _trans_date_time = value; }
}
private int _date_time_offset;

public int date_time_offset
{
get { return _date_time_offset; }
set { _date_time_offset = value; }
}
private string _tkt_code;

public string tkt_code
{
get { return _tkt_code; }
set { _tkt_code = value; }
}
private string _order_code;

public string order_code
{
get { return _order_code; }
set { _order_code = value; }
}
private DateTime _tkt_date_time;

public DateTime tkt_date_time
{
get { return _tkt_date_time; }
set { _tkt_date_time = value; }
}
private string _truck_code;

public string truck_code
{
get { return _truck_code; }
set { _truck_code = value; }
}
private string _employee_code;

public string employee_code
{
get { return _employee_code; }
set { _employee_code = value; }
}
private string _message_string;

public string message_string
{
get { return _message_string; }
set { _message_string = value; }
}
private string _message;

public string message
{
get { return _message; }
set { _message = value; }
}
private string _trans_cat;

public string trans_cat
{
get { return _trans_cat; }
set { _trans_cat = value; }
}
private string _trans_type;

public string trans_type
{
get { return _trans_type; }
set { _trans_type = value; }
}
private string _trans_sub_type;

public string trans_sub_type
{
get { return _trans_sub_type; }
set { _trans_sub_type = value; }
}
private string _trans_origin;

public string trans_origin
{
get { return _trans_origin; }
set { _trans_origin = value; }
}
private string _trans_origin_IPAddr;

public string trans_origin_IPAddr
{
get { return _trans_origin_IPAddr; }
set { _trans_origin_IPAddr = value; }
}
private string _trans_origin_machname;

public string trans_origin_machname
{
get { return _trans_origin_machname; }
set { _trans_origin_machname = value; }
}
private string _trans_origin_username;

public string trans_origin_username
{
get { return _trans_origin_username; }
set { _trans_origin_username = value; }
}
private int _time_to_live;

public int time_to_live
{
get { return _time_to_live; }
set { _time_to_live = value; }
}
}
Nov 22 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Andy Fish | last post: by
5 posts views Thread by Geoff | last post: by
2 posts views Thread by Thomas S | last post: by
6 posts views Thread by Redowl | last post: by
9 posts views Thread by =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.