0

I have this XML feed file and I don`t know how to handle a problem. So, the code is:

<PRICE>
<WIC>GA-H110M-S2H</WIC>
<DESCRIPTION>
GIGABYTE Main Board Desktop INTEL H110 (Socket LGA1151,2xDDR4,VGA/HDMI/DVI,1xPCIEX16/2xPCIEX1,USB3.0/USB2.0, 6xSATA III,LAN) micro ATX retail
</DESCRIPTION>
<VENDOR_NAME>GIGABYTE</VENDOR_NAME>
<GROUP_NAME>Main Board Desktop</GROUP_NAME>
<VPF_NAME/>
<CURRENCY_CODE>USD</CURRENCY_CODE>
<AVAIL>0</AVAIL>
<RETAIL_PRICE>56.40</RETAIL_PRICE>
<MY_PRICE>52.71</MY_PRICE>
<WARRANTYTERM>36</WARRANTYTERM>
<GROUP_ID>32</GROUP_ID>
<VENDOR_ID>170192</VENDOR_ID>
<SMALL_IMAGE>
https://www.it4profit.com/catalogimg/wic/1/GA-H110M-S2H
</SMALL_IMAGE>
<PRODUCT_CARD>
https://content.it4profit.com/itshop/itemcard_cs.jsp?ITEM=151118121920215716&THEME=asbis&LANG=ro
</PRODUCT_CARD>
<EAN>4719331837310</EAN>
</PRICE>

Now, in PRODUCT_CARD are technical information for that product and I don`t know how to extract all data and then export to .csv using C# for example.

jdweng
  • 33,250
  • 2
  • 15
  • 20

2 Answers2

0

I haven't tried , but I am suggesting can do , this Credits: Pulling data from a webpage, parsing it for specific pieces, and displaying it

    string Url = "https://content.it4profit.com/itshop/itemcard_cs.jsp?ITEM=151118121920215716&THEME=asbis&LANG=ro";
        HtmlWeb web = new HtmlWeb();
        HtmlDocument doc = web.Load(Url);
Urvil Shah
  • 73
  • 9
  • Did you just copy the xpath from the answer in that link? – Han Jul 11 '17 at 18:34
  • @hans , yes , although I have edited it, did for reference. – Urvil Shah Jul 11 '17 at 18:39
  • I think you should edit your answer. This code only loads the page, not parsing it. And the previous code might use the wrong xpath. I think it's better to post code that works or just post the link so TC or readers can do something by themselves based on the answer in that link. – Han Jul 11 '17 at 19:23
0

Real simple to get into dictionary

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;

namespace ConsoleApplication1
{
    class Program
    {
        const string FILENAME = @"c:\temp\test.xml";
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);

            Dictionary<string, string> dict = doc.Descendants("PRICE").Elements()
                .GroupBy(x => x.Name.LocalName, y => (string)y)
                .ToDictionary(x => x.Key, y => y.FirstOrDefault());
        }
    }
}
jdweng
  • 33,250
  • 2
  • 15
  • 20