DevTreks.Data/EditHelpers/XmlIO.cs
/// <summary>
/// Append children node in an xml document to a referenced element node
/// </summary>
/// <param name="rootQry"></param>
/// <param name="fullDoc"></param>
/// <param name="element"></param>
Append children node in an xml document to a referenced element node
Append children node in an xml document to a referenced element node
public static void AppendChildrenOnly(string rootQry, XmlDocument fullDoc, ref XmlElement element)
        {
            XPathNodeIterator oGroupIterator = fullDoc.CreateNavigator().Select(rootQry);
            if (oGroupIterator != null)
            {
                while (oGroupIterator.MoveNext())
                {
                    XPathNavigator nav2 = oGroupIterator.Current.Clone();
                    if (nav2.HasChildren == true)
                    {
                        XPathNodeIterator oChildrenIterator = nav2.SelectChildren(XPathNodeType.Element);
                        while (oChildrenIterator.MoveNext())
                        {
                            XmlElement oGroupChild = (XmlElement)((IHasXmlNode)oChildrenIterator.Current).GetNode().CloneNode(false);
                            if (oGroupChild != null)
                            {
                                element.AppendChild(oGroupChild);
                            }
                        }
                    }
                }
            }
        }
public static void AppendChildrenOnly ( string rootQry , XmlDocument fullDoc , ref XmlElement element ) { XPathNodeIterator oGroupIterator = fullDoc . CreateNavigator ( ) . Select ( rootQry ) ; if ( oGroupIterator != null ) { while ( oGroupIterator . MoveNext ( ) ) { XPathNavigator nav2 = oGroupIterator . Current . Clone ( ) ; if ( nav2 . HasChildren == true ) { XPathNodeIterator oChildrenIterator = nav2 . SelectChildren ( XPathNodeType . Element ) ; while ( oChildrenIterator . MoveNext ( ) ) { XmlElement oGroupChild = ( XmlElement ) ( ( IHasXmlNode ) oChildrenIterator . Current ) . GetNode ( ) . CloneNode ( false ) ; if ( oGroupChild != null ) { element . AppendChild ( oGroupChild ) ; } } } } } }
Append children node in an xml document to a referenced element node
Append children node in an xml document to a referenced element node
//clone the child //clone it //append it to the parent
rootQry
string
None
fullDoc
XmlDocument
None
XmlElement
ref
element
None