I know you found an answer but i wanted to put what i did to get it to function properly just for fun :) here is the code that i used:
using System;
using System.Xml;
using System.Xml.Linq;
namespace xmlTesting
{
public class codeList
{
public string Name { get; set; }
public string Description { get; set; }
public string Version { get; set; }
public DateTime EffectiveDate { get; set; }
public DateTime ExpirationDate { get; set; }
}
class program {
static void Main(string[] args)
{
var CL = UploadXml(XElement.Load(@"c:\debug\xmlcontent.xml"));
Console.WriteLine(
string.Format("name: {0}\nDesc: {1}\nVersion: {2}\nEffectivdate: {3}\nExp: {4}"
, CL.Name, CL.Description, CL.Version, CL.EffectiveDate, CL.ExpirationDate)
);
Console.ReadKey(true);
}
public static codeList UploadXml(XElement xdoc)
{
var codeList = new codeList();
foreach (XElement XE in xdoc.Descendants())
{
switch (XE.Name.LocalName)
{
case "CODELIST_NAME":
codeList.Name = XE.Value;
break;
case "DESCRIPTION":
if(codeList.Description == null)
codeList.Description = XE.Value;
break;
case "VERSION":
codeList.Version = XE.Value;
break;
case "EFFECTIVE_DATE":
codeList.EffectiveDate = DateTime.Parse(XE.Value);
break;
case "EXPIRATION_DATE":
codeList.ExpirationDate = DateTime.Parse( XE.Value);
break;
}
}
// save code list
// get code list ID
// create codes
return codeList;
}
}
}
and the xml that i used was this.
<?xml version="1.0" encoding="utf-8"?>
<CONTEXT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/2000/xmlns">
<CONTEXT_NAME></CONTEXT_NAME>
<CODELIST>
<CODELIST_NAME>a name</CODELIST_NAME>
<DESCRIPTION>a desr</DESCRIPTION>
<VERSION>test1.1</VERSION>
<USERNAME>test user</USERNAME>
<OWNER_TEAM />
<STEWARD_TEAM />
<STATUS></STATUS>
<LAST_MODIFIED>a day</LAST_MODIFIED>
<LAST_MODIFIED_NAME>trae</LAST_MODIFIED_NAME>
<EFFECTIVE_DATE>07/05/1983</EFFECTIVE_DATE>
<EXPIRATION_DATE>07/05/1983</EXPIRATION_DATE>
<FILE_TIMESTAMP></FILE_TIMESTAMP>
<CONSTRAINED_VALUE>
<CODE></CODE>
<PARENT_ID />
<NAME></NAME>
<DESCRIPTION></DESCRIPTION>
</CONSTRAINED_VALUE>
</CODELIST>
</CONTEXT>