Hi Experts,
Having the following XML file sample:
<App action="A" id="1">
<BaseVeh id="123" />
<Qty>1</Qty>
<PartType id="123" />
<Part>part name</Part>
</App>
I want to read the whole nodes/comments and save to SQL table.
I managed to read all the nodes, save them no problem, also managed to read all comments and save them in separate table too.
I want to save the comment alongside the corresponding node, in other words, if i'm saving
partTypeId i want to save it's comment too in the same table, is it possible to do so?
What I have tried:
Here's how I read the XML and save:
XmlDocument mydoc = new XmlDocument();
mydoc.Load("https://abc/file.xml");
XmlElement element = mydoc.DocumentElement;
XmlNodeList nodes = element.SelectNodes("App");
foreach (XmlNode node in nodes)
{
if (node != null)
{
}
}
This is what I used to save comments separately:
XDocument Doc=XDocument.Load("https://abc/file.xml");
foreach (var node in Doc.Descendants("App").Nodes())
{
if (node is XComment)
{
}