Hi , This is turning out to be a nightmare. I have an XML file where I want to extract two pieces of data and put it into a dictionary. I have asked this question on other forums and nobody has given me an example that even remotely works. I have spent hours and hours trying to figure this out and nowhere is there an overview or info the help.
I've been told to use XMLReader, xml.linq, HTML Agility pack...and all examples are just so different from each other it's tough to decipher where to go!! AhhhhhGGG!
Ok, so here's hoping someone here can help out!
Here is the XML file. I want to put adif value as the key in a dictionary and name in as well.
<?xml version="1.0"?>
-<clublog xmlns="http://www.clublog.org/cty/v1.0" date="2014-03-15T08:30:04+00:00">
-<entities>
-<entity>
<adif>1</adif>
<name>CANADA</name>
<prefix>VE</prefix>
<deleted>FALSE</deleted>
<cqz>5</cqz>
<cont>NA</cont>
<long>-80.00</long>
<lat>45.00</lat>
</entity>
-<entity>
<adif>2</adif>
<name>ABU AIL IS</name>
<prefix>A1</prefix>
<deleted>TRUE</deleted>
<cqz>21</cqz>
<cont>AS</cont>
<long>45.00</long>
<lat>12.80</lat>
<end>1991-03-30T23:59:59+00:00</end>
</entity>
The code I have so far is
private void button1_Click(object sender, EventArgs e)
{
var dict = (Dictionary<string, decimal>)null;
using (WebClient wc = new WebClient())
{
wc.DownloadFile("https://secure.clublog.org/cty.php?api=1", "Test.gz");
using (var file = File.Open("Test.gz", FileMode.Open))
{
using (var zip = new GZipStream(file, CompressionMode.Decompress))
{
using (var xmlReader = XmlReader.Create(zip))
{
//and at this point, I have no clue at all.
}
}
}
}
I have tried many examples that people have given me, and then I either have errors or just null values.
Can someone please help out here?
Thanks, Tom