I have used this Code all throughout my project and now that there has been an update it has stopped working. I cant find anything online this is the format I'm trying to get my XML
<?xml version="1.0" encoding="utf-8" ?>
<CATALOG>
<ITEM>
<UIElementIndex>GRID</UIElementIndex>
<Left>0</Left>
<Top>0</Top>
<Width>595</Width>
<Height>60</Height>
<Name>Header</Name>
<PlaceHolder></PlaceHolder>
<R>170</R>
<G>170</G>
<B>170</B>
</ITEM>
</CATALOG>
I have been using this code, am i doing something Wrong
using (var stream = await PDFCRFileReader.Instance.MainFile.OpenStreamForWriteAsync())
{
foreach (PDFCRElement element in PDFCRFileReader.Instance.documentElements)
{
XDocument document = XDocument.Load(stream);
XElement xmlElemnt = new XElement("ITEM",
new XAttribute("ID", "NIT " + element.Name + ((element.Left * element.Top) * element.Width).ToString()),
new XElement("UIElementIndex", element.UIElementIndex),
new XElement("Left", element.Left),
new XElement("Top", element.Top),
new XElement("Width", element.Width),
new XElement("Height", element.Height),
new XElement("Name", element.Name),
new XElement("PlaceholderText", element.PlaceholderText),
new XElement("R", element.R),
new XElement("B", element.B),
new XElement("G", element.G));
document.Root.Element("CATALOG").Add(xmlElemnt);
document.Save(stream);
var dialog = new MessageDialog("FIle Saved!", "FILE SAVE STATUS");
await dialog.ShowAsync();
}
stream.Flush();
}
I am getting the error, it makes no sense that this was working yesterday
System.NullReferenceException: 'Object reference not set to an instance of an object.'