XMLFile1.xml:
XDocument Contacts = XDocument.Load("XMLFile1.xml");
//XElement Contacts = XElement.Parse(xmldata);
var Elist = from t in Contacts.Descendants("HEADER")
select new
{
CREATION_DATE = t.Element("CREATION_DATE").Value.Replace("
", ""),
ITEM_NUMBER = t.Element("ITEM_NUMBER").Value.Replace("
", ""),
ITEM_DESC = t.Element("ITEM_DESC").Value.Replace("
", ""),
ITEM_CATEGORY_CODE = t.Element("ITEM_CATEGORY_CODE").Value.Replace("
", ""),
PRIMARY_UOM_CODE = t.Element("PRIMARY_UOM_CODE").Value.Replace("
", "") //注意此处用到 attribute
};
XDocument Contacts =XDocument.Load("XMLFile1.xml");
//XElement Contacts = XElement.Parse(xmldata);
var Elist =from t in Contacts.Descendants("HEADER")
selectnew
{
CREATION_DATE = t.Element("CREATION_DATE").Value.Replace(" ", ""),
ITEM_NUMBER = t.Element("ITEM_NUMBER").Value.Replace(" ", ""),
ITEM_DESC = t.Element("ITEM_DESC").Value.Replace(" ", ""),
ITEM_CATEGORY_CODE = t.Element("ITEM_CATEGORY_CODE").Value.Replace(" ", ""),
PRIMARY_UOM_CODE = t.Element("PRIMARY_UOM_CODE").Value.Replace(" ", "") //注意此处用到 attribute
};