Hi,
Im trying to deserialize the string with the following content:
"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<report>
<report-name name='Custom Adgroup Performance Report'/>
<date-range date='Mar 25, 2015-Mar 31, 2015'/>
<table>
<columns>
<column name='campaignID' display='Campaign ID'/>
<column name='adGroupID' display='Ad group ID'/>
<column name='impressions' display='Impressions'/>
<column name='clicks' display='Clicks'/>
<column name='cost' display='Cost'/>
</columns>
<row campaignID='268503015' adGroupID='19443549735' impressions='0' clicks='0' cost='0'/>
<row campaignID='268503015' adGroupID='19474365615' impressions='0' clicks='0' cost='0'/>
<row campaignID='268503615' adGroupID='19443569895' impressions='0' clicks='0' cost='0'/>
<row campaignID='268503615' adGroupID='19443570015' impressions='0' clicks='0' cost='0'/>
<row campaignID='268503615' adGroupID='19443570135' impressions='0' clicks='0' cost='0'/>
</table>
</report>"
This is my code:
The Problem is that I cant put my String directly into the Deserializer so I tried to go over XmlReader.
But this throws an Exeption "System.IO.DirectoryNotFoundException: Could not find a part of the path"
Does anybody know how to work with a string to deserialize?
`
XmlSerializer serializer = new XmlSerializer(typeof(Report));
XmlReaderSettings settings = new XmlReaderSettings();
var reader = XmlReader.Create(stringToDeserialize);
var list = serializer.Deserialize(reader);
[XmlRootAttribute(ElementName = "report")]
public class Report
{
[XmlElementAttribute("table")]
public ReportTable Table { get; set; }
}
public class ReportTable
{
[XmlElementAttribute("columns")]
public Columns Table { get; set; }
[XmlArray("row")]
[XmlArrayItemAttribute("campaignID")]
public string[] campaignID { get; set; }
[XmlArrayItemAttribute("adGroupID")]
public string[] adGroupID { get; set; }
[XmlArrayItemAttribute("impressions")]
public string[] impressions { get; set; }
[XmlArrayItemAttribute("clicks")]
public string[] clicks { get; set; }
[XmlArrayItemAttribute("cost")]
public string[] cost { get; set; }
}
public class Columns
{
[XmlArray("column")]
[XmlArrayItemAttribute("name")]
public string[] name { get; set; }
[XmlArrayItemAttribute("display")]
public string[] display { get; set; }
}
`