private AsXMLElement ExtractXML(XElement node) { if (node.NodeType == XmlNodeType.Element) { AsXMLElement element = new AsXMLElement(node.Name.LocalName); IEnumerable<XAttribute> attributes = node.Attributes(); foreach (XAttribute attr in attributes) { element.appendAttribute(attr.Name.LocalName, attr.Value); } IEnumerable<XElement> childs = node.Elements(); foreach (XElement child in childs) { AsXMLElement childElement = ExtractXML(child); if (childElement != null) { element.appendChild(childElement); } } return element; } return null; }
private AsXMLElement ExtractXML(XmlNode node) { if (node.NodeType == XmlNodeType.Element) { AsXMLElement element = new AsXMLElement(node.Name); XmlAttributeCollection attributes = node.Attributes; foreach (XmlAttribute attr in attributes) { element.appendAttribute(attr.Name, attr.Value); } XmlNodeList childs = node.ChildNodes; foreach (XmlNode child in childs) { AsXMLElement childElement = ExtractXML(child); if (childElement != null) { element.appendChild(childElement); } } return element; } return null; }