public void AddPI(object doc, string data)
        {
            XmlDocument xmlDocument = InMetaXmlUtils.TryGetXmlDocument(doc);

            if (xmlDocument != null)
            {
                XmlNode firstChild = xmlDocument.FirstChild;
                if (firstChild != null && (firstChild.NodeType == XmlNodeType.ProcessingInstruction && firstChild.Name == "xml"))
                {
                    xmlDocument.RemoveChild(firstChild);
                }
                XmlProcessingInstruction processingInstruction = xmlDocument.CreateProcessingInstruction("xml", data);
                xmlDocument.InsertBefore((XmlNode)processingInstruction, xmlDocument.FirstChild);
            }
            else
            {
                object firstChild = InMetaXmlUtils.InteropGetFirstChild(doc);
                if (firstChild != null && (InMetaXmlUtils.InteropGetNodeType(firstChild) == 7 && InMetaXmlUtils.InteropGetNodeName(firstChild) == "xml"))
                {
                    InMetaXmlUtils.InteropRemoveChild(doc, firstChild);
                }
                object processingInstruction = InMetaXmlUtils.InteropCreateProcessingInstruction(doc, "xml", data);
                InMetaXmlUtils.InteropInsertBefore(doc, processingInstruction, InMetaXmlUtils.InteropGetFirstChild(doc));
            }
        }