2

Here is the invalid xml response I need to parse with C#, I'm trying to create a class for the responses and have had little success.

<Response service=\"RouteService\">
<Head>OK</Head>
<Body>
    <RouteResponse mailno=\"070033764942\">
        <Route accept_time=\"2017-03-23 10:57:13\"\taccept_address=\"United States\"\tremark=\"For Sign Info, please see 'AWB Info &amp; POD' in our website\"\topcode=\"8000\"/>
        <Route accept_time=\"2017-03-23 10:52:10\"\taccept_address=\"United States\"\tremark=\"Have been signed(MS.TT),Thank you for using SF, and looking forward to serving you again\"\topcode=\"80\"/>
        <Route accept_time=\"2017-03-23 10:52:10\"\taccept_address=\"United States\"\tremark=\"Have been signed(MS.TT),Thank you for using SF, and looking forward to serving you again\"\topcode=\"80\"/>
        <Route accept_time=\"2017-03-23 10:46:37\"\taccept_address=\"SHENZHEN CITY\"\tremark=\"S.F. Express has picked up the shipment\"\topcode=\"50\"/>
        <Route accept_time=\"2017-03-23 10:46:37\"\taccept_address=\"SHENZHEN CITY\"\tremark=\"S.F. Express has picked up the shipment\"\topcode=\"50\"/>
    </RouteResponse>
</Body>

Ryan Dooley
  • 224
  • 1
  • 3
  • 16

1 Answers1

3

It sounds like you're trying to use the standard C# XML libraries to parse a non-legal XML file.

That won't work. You need to make the file "valid" first.

SUGGESTION:

  1. Read the XML text into a string.

  2. Replace all \" with ".

  3. Use the standard libraries to parse the "corrected" XML.

paulsm4
  • 114,292
  • 17
  • 138
  • 190