Advertisement

07.03.2008 at 12:38PM PDT, ID: 23537966
[x]
Attachment Details

Deserialize tricky XML

Asked by jcoehoorn in .NET Framework 2.x, Extensible Markup Language (XML), .NET

Tags: ,

We receive xml files from clients that I deserialize into objects.  The objects are then processed for import into our system.  I have one client that sends some xml that is not quite well-formed.  Each record is divided into segments (called lines).  Each line holds a different part of the object I'm importing, so there will always be one instance of each line (in order) per record.  But there is no single element that encompasses an entire record.  There can, however, be several records per file, and I'm not quite sure how to deserialize the file into a collection of objects.

Here's an example of what a file might look like (dashed lines added by me to delimit records):

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
<?xml version="1.0"?>
<root>
----------------------
<line1>
<value1>some data</value1>
<value2>more data</value2>
....
</line1>
<line2>
<othervalue>different data</othervalue>
</line2>
---------------------
<line1>
<value1>yet more data</value1>
<value2>something here</value2>
</line1>
<line2>
<othervalue>last data in this file</othervalue>
</line2>
---------------------
</root>
[+][-]07.03.2008 at 03:22PM PDT, ID: 21929845

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.03.2008 at 03:57PM PDT, ID: 21930004

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.04.2008 at 12:16AM PDT, ID: 21931446

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET Framework 2.x, Extensible Markup Language (XML), .NET
Tags: .Net 2.0, XML Serialization
Sign Up Now!
Solution Provided By: ozymandias
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628