Beispiel #1
0
        private static IXMLTreeStructure xmlWalker(XElement node)
        {
            var output = new XmlTreeStructure(node.Name.LocalName, null)
            {
                Namespaces = node.Attributes().Where(x => x.IsNamespaceDeclaration).
                             ToDictionary(x => x.Name.LocalName, x => x.Value),
                Value = node.Value
            };

            foreach (var attribute in node.Attributes().Where(x => !output.Namespaces.Keys.Contains(x.Name.LocalName)))
            {
                output.AddAttribute(attribute.Name.LocalName, attribute.Value);
            }
            var descendants = node.Elements();
            var descNodes   = node.DescendantNodes();

            foreach (var descendant in descendants)
            {
                output.AddChild(xmlWalker(descendant));
            }
            return(output);
        }