Consider I have a XML something like this ( Goal is to return a dictionary with keyValuePair of key =owner, and value =element name ( ie personal or business ) - how do I get at just the childNode Name ??
<cars>
<car ownerID ='1234'>
<personal someattribute="">
</car>
<car ownerID ='1445'>
<business someattribute="">
</car>
</cars>
public Dictionary<string,string> GetElementsAttributeWithFirstNodeName(string XMLFragSource, string elementName, string attributeName) { var myKeyValReturn = new Dictionary<string, string> (); // once subnode name can be returned. XElement allData = XElement.Parse(XMLFragSource); if (allData != null) { IEnumerable<XElement> Test_Elements = allData.Descendants(elementName); foreach (XElement telement in Test_Elements) // retVal.Add(telement.Attribute(attributeName).Value + "type=" + telement.FirstNode); // want nodeName of firstNode myKeyValReturn.Add(telement.Attribute(attributeName).Value, "looking for telement.FirstNode.Name"); } return myKeyValReturn; }
Thanks !!!
andrew