DevTreks.Data/EditHelpers/XmlIO.cs
/// <summary>
/// Returns just the nodes needed in a full doc which is too large to serve to clients
/// </summary>
/// <param name="fullDoc"></param>
/// <param name="rootQry"></param>
/// <param name="parentQry"></param>
/// <param name="partDoc"></param>
Returns just the nodes needed in a full doc which is too large to serve to clients
Returns just the nodes needed in a full doc which is too large to serve to clients
public static void FixFullDoc(XmlDocument fullDoc, string rootQry, string parentQry, string root, out XmlDocument partDoc)
        {
            partDoc = new XmlDocument();
            XmlElement oRootElement = partDoc.CreateElement(root);
            if (fullDoc.DocumentElement.HasChildNodes == true)
            {
                XmlElement oGroupElement = (XmlElement)fullDoc.SelectSingleNode(rootQry).CloneNode(false);
                if (oGroupElement != null)
                {
                    AppendChildrenOnly(rootQry, fullDoc, ref oGroupElement);
                    if (parentQry != string.Empty && parentQry != null)
                    {
                        XmlElement oParentElement = (XmlElement)fullDoc.SelectSingleNode(parentQry).CloneNode(false);
                        if (oParentElement != null)
                        {
                            AppendChildrenOnly(parentQry, fullDoc, ref oParentElement);
                            oGroupElement.AppendChild(oParentElement);
                        }
                    }
                    XmlNode oNodeToInsert = partDoc.ImportNode(oGroupElement, true);
                    oRootElement.AppendChild(oNodeToInsert);
                    partDoc.AppendChild(oRootElement);
                }
            }
        }
public static void FixFullDoc ( XmlDocument fullDoc , string rootQry , string parentQry , string root , out XmlDocument partDoc ) { partDoc = new XmlDocument ( ) ; XmlElement oRootElement = partDoc . CreateElement ( root ) ; if ( fullDoc . DocumentElement . HasChildNodes == true ) { XmlElement oGroupElement = ( XmlElement ) fullDoc . SelectSingleNode ( rootQry ) . CloneNode ( false ) ; if ( oGroupElement != null ) { AppendChildrenOnly ( rootQry , fullDoc , ref oGroupElement ) ; if ( parentQry != string . Empty && parentQry != null ) { XmlElement oParentElement = ( XmlElement ) fullDoc . SelectSingleNode ( parentQry ) . CloneNode ( false ) ; if ( oParentElement != null ) { AppendChildrenOnly ( parentQry , fullDoc , ref oParentElement ) ; oGroupElement . AppendChild ( oParentElement ) ; } } XmlNode oNodeToInsert = partDoc . ImportNode ( oGroupElement , true ) ; oRootElement . AppendChild ( oNodeToInsert ) ; partDoc . AppendChild ( oRootElement ) ; } } }
Returns just the nodes needed in a full doc which is too large to serve to clients
Returns just the nodes needed in a full doc which is too large to serve to clients
//get the element being appended directly to to the root //get the children of this node too //append the child needed to the parent if it has a good parent query //get the children of this node too //append both to the root element
fullDoc
XmlDocument
None
rootQry
string
None
parentQry
string
None
root
string
XmlDocument
out
partDoc
None