Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting the value of XML tag xith XMLReader and add to LinkedList C#
    primarykey
    data
    text
    <p>I am a new to programming, and have a serious problem and cant get out of it.</p> <p>I have 5 XML URLs. such as <a href="http://www.shopandmiles.com/xml/3_119_3.xml" rel="nofollow">http://www.shopandmiles.com/xml/3_119_3.xml</a></p> <p>This is an XML URL which I have to get values and write to database in related columns. My column names and XML tag names do match.</p> <p>When I write the below code, reader element miss null xml values. Some tags do not have value inside. I have to add them null to linkedlist because after that code, i am going through the linked list but the order doesnt match if ı cant add a value for null xml values. So column names and data inside doesnt match. i lose the order. My all code is here, you can also check comment in the code if that helps. Thank you all.</p> <pre><code>public void WebServiceShopMilesCampaignsXMLRead(string URL) { XmlReader reader = XmlReader.Create(URL); LinkedList&lt;string&gt; linkedList = new LinkedList&lt;string&gt;(); List&lt;ShopAndMilesCampaigns&gt; shopMileCampaigns = new List&lt;ShopAndMilesCampaigns&gt;(); try { while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Text: linkedList.AddLast(reader.Value); break; } } } catch (XmlException exception) { Console.WriteLine("XML okurken bir sorun oluştu, hata detayı --&gt; " + exception.Message); } LinkedListNode&lt;string&gt; node = linkedList.First; while (node != null) { ShopAndMilesCampaigns shopMilesCampaign = new ShopAndMilesCampaigns(); shopMilesCampaign.Name = node.Value; // Null values mixes up the order because i cant add as null with reader.read above node = node.Next; shopMilesCampaign.Summary = node.Value; node = node.Next; shopMilesCampaign.AccountName = node.Value; node = node.Next; shopMilesCampaign.Category = node.Value; node = node.Next; shopMilesCampaign.Sector = node.Value; node = node.Next; shopMilesCampaign.Details = node.Value; node = node.Next; shopMilesCampaign.Image = node.Value; node = node.Next; shopMilesCampaign.Status = 1; node = node.Next; shopMileCampaigns.Add(shopMilesCampaign); } foreach (ShopAndMilesCampaigns shopMileCampaign in shopMileCampaigns) { shopMileCampaign.Insert(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload