0

I am trying to take XML data from a SOAP response and turn that data into ReportData objects that will populate a list (the objects classes are already made in code). I am unable to access the info I need because it is wrapped in CDATA. Below is the XML I'm trying to parse:

<strReportDataCollection><![CDATA[<ArrayOfReportData>
<ReportData>
  <Archived>false</Archived>
  <Floor>1</Floor>
  <Camera>1</Camera>
  <ReportID>123456</ReportID>
  <Station>1</Station>
</ReportData>
<ReportData>
  <Archived>false</Archived>
  <Floor>2</Floor>
  <Camera>4</Camera>
  <ReportID>789000</ReportID>
  <Station>1</Station>
</ReportData>
</ArrayOfReportData>]]></strReportDataCollection>

I've seen examples of reading/parsing values from one specific node covered by CDATA but have not been able to extrapolate that into what I'm trying to achieve. Any tips?

  • If you simply want to extract the embedded XML as a string, see [Extracting data from CDATA using LINQ to XML](https://stackoverflow.com/q/3720076/3744182) or [Decode CDATA section in C#](https://stackoverflow.com/q/1236785/3744182). If you want to deserialize the outer `strReportDataCollection` type using `XmlSerializer` and automatically deserialize the elements inside the embedded CDATA see [Wrap properties with CData Section - XML Serialization C#](https://stackoverflow.com/q/34128757/3744182). Do those answer your question or do you need more specific help? – dbc Jul 30 '18 at 19:31
  • @dbc yes, that last link did help, thank you :) – Mojo Rising Jul 30 '18 at 20:00
  • Glad to help. Close as a duplicate then? – dbc Jul 30 '18 at 20:10
  • @dbc okay, sure – Mojo Rising Aug 01 '18 at 14:41

0 Answers0