Stream(System.Xml.XmlNode node) { m_dataObjs.Add(new Snoop.Data.ClassSeparator(typeof(System.Xml.XmlNode))); m_dataObjs.Add(new Snoop.Data.String("Node type", node.NodeType.ToString())); m_dataObjs.Add(new Snoop.Data.String("Name", node.Name)); m_dataObjs.Add(new Snoop.Data.String("Local name", node.LocalName)); m_dataObjs.Add(new Snoop.Data.String("Value", node.Value)); m_dataObjs.Add(new Snoop.Data.Bool("Has child nodes", node.HasChildNodes)); m_dataObjs.Add(new Snoop.Data.String("Inner text", node.InnerText)); m_dataObjs.Add(new Snoop.Data.Xml("Inner XML", node.InnerXml, false)); m_dataObjs.Add(new Snoop.Data.Xml("Outer XML", node.OuterXml, false)); m_dataObjs.Add(new Snoop.Data.Bool("Is read only", node.IsReadOnly)); m_dataObjs.Add(new Snoop.Data.String("BaseURI", node.BaseURI)); m_dataObjs.Add(new Snoop.Data.String("Namespace URI", node.NamespaceURI)); m_dataObjs.Add(new Snoop.Data.String("Prefix", node.Prefix)); // branch to all known major sub-classes System.Xml.XmlAttribute att = node as System.Xml.XmlAttribute; if (att != null) { Stream(att); return; } System.Xml.XmlDocument doc = node as System.Xml.XmlDocument; if (doc != null) { Stream(doc); return; } System.Xml.XmlDocumentFragment docFrag = node as System.Xml.XmlDocumentFragment; if (docFrag != null) { Stream(docFrag); return; } System.Xml.XmlEntity ent = node as System.Xml.XmlEntity; if (ent != null) { Stream(ent); return; } System.Xml.XmlNotation notation = node as System.Xml.XmlNotation; if (notation != null) { Stream(notation); return; } System.Xml.XmlLinkedNode lnkNode = node as System.Xml.XmlLinkedNode; if (lnkNode != null) { Stream(lnkNode); return; } }
/// <summary> /// Append xml into 'text' string after node 'parent' in root/nodes /// </summary> /// <param name="text">xml string to insert</param> /// <param name="parent">xmlnode parent under root/nodes</param> public void Text2Xml(string text, System.Xml.XmlNode parent) { System.Xml.XmlNode xmlParent = FindXmlNodeByGuid(GetAttributeByName(parent, PazDocumentLegacy.TAG_GUID)); System.Xml.XmlDocumentFragment frag = xmlDoc.CreateDocumentFragment(); frag.InnerXml = text; parent.ParentNode.InsertAfter(frag, parent); }
public void Dispose() { if (_closeWriter) { _wr.Close(); string str = _sb.ToString(); _wr = null; _tw = null; _sb = null; if (_cnt > 1) { lock (this.GetType()) { System.Xml.XmlDocument xdoc = null; bool cl = xdoc == null; if (cl) { xdoc = new System.Xml.XmlDocument(); if (!System.IO.File.Exists(_fn)) { System.Xml.XmlElement root = xdoc.CreateElement("root"); xdoc.AppendChild(root); } else { xdoc.Load(_fn); } } System.Xml.XmlDocumentFragment e = xdoc.CreateDocumentFragment(); e.InnerXml = str; xdoc.DocumentElement.AppendChild(e); if (cl) { xdoc.Save(_fn); xdoc = null; } } } _cnt = 0; } else { _wr.WriteEndElement(); } //lock (typeof(CSScopeMgr_Debug)) //{ // if (_first) // { // _xdoc.Save(_fn); // _xdoc = null; // } //} Unlock(_lock_obj); }
public void replaceItemNode(string newxml) { System.Xml.XmlDocumentFragment fragdoc = xmlDoc.CreateDocumentFragment(); fragdoc.InnerXml = newxml; string guid = GetAttributeByName(fragdoc.FirstChild, PazDocumentLegacy.TAG_GUID); System.Xml.XmlNode node = FindXmlNodeByGuid(guid); node.ParentNode.ReplaceChild(fragdoc.FirstChild, node); }
public void InsertAfter(string xmlString, System.Xml.XmlNode xParentItem) { System.Xml.XmlDocumentFragment fragdoc = xmlDoc.CreateDocumentFragment(); fragdoc.InnerXml = xmlString; if (xParentItem != null) { xParentItem.ParentNode.InsertAfter(fragdoc, xParentItem); } else { System.Xml.XmlNode nodes = GetNodesItem(); nodes.AppendChild(fragdoc); } }
} // End Sub AddOrReplaceParameter public static void AddCustomParameter(string strFilename, System.Xml.XmlNode xnInsertHere, bool bFirst, bool bLast, string strXmlFragment) { string strReportName = System.IO.Path.GetFileNameWithoutExtension(strFilename); if (xnInsertHere != null) { Logging.LogMessage("{0}\t{1}", strReportName, "hasParameters"); System.Xml.XmlDocument doc = xnInsertHere.OwnerDocument; System.Xml.XmlDocumentFragment xmlDocFrag = doc.CreateDocumentFragment(); xmlDocFrag.InnerXml = strXmlFragment; bool bDoNotFechParameter = bFirst || bLast; if (bDoNotFechParameter) { if (bFirst) { xnInsertHere.PrependChild(xmlDocFrag); } else { xnInsertHere.AppendChild(xmlDocFrag); } } else { if (StringComparer.InvariantCultureIgnoreCase.Equals(xnInsertHere.LocalName, "ReportParameters")) { xnInsertHere.AppendChild(xmlDocFrag); } else { xnInsertHere.ParentNode.InsertAfter(xmlDocFrag, xnInsertHere); } } // End else of if (bDoNotFechParameter) XmlTools.SaveDocument(doc, strFilename, true); } // End if (xn else { Logging.LogMessage("{0}\tKeine Parameter in Report.", strReportName); } } // End Sub AddCustomParameter
} // End Function GetDataSetDefinition public static void AddMainParametersNode(string strFilename) { if (HasParameters(strFilename)) { return; } System.Xml.XmlNode xnDataSets = GetDataSetsNode(strFilename); if (xnDataSets == null) { return; } System.Xml.XmlDocument doc = xnDataSets.OwnerDocument; System.Xml.XmlDocumentFragment xmlDocFrag = doc.CreateDocumentFragment(); xmlDocFrag.InnerXml = "<ReportParameters></ReportParameters>"; xnDataSets.ParentNode.InsertAfter(xmlDocFrag, xnDataSets); XmlTools.SaveDocument(doc, strFilename, true); }
public static bool _CreateDocumentFragment_System_Configuration_ConfigXmlDocument( ) { //Parameters //ReturnType/Value System.Xml.XmlDocumentFragment returnVal_Real = null; System.Xml.XmlDocumentFragment returnVal_Intercepted = null; //Exception Exception exception_Real = null; Exception exception_Intercepted = null; InterceptionMaintenance.disableInterception( ); try { returnValue_Real = System.Configuration.ConfigXmlDocument.CreateDocumentFragment(); } catch (Exception e) { exception_Real = e; } InterceptionMaintenance.enableInterception( ); try { returnValue_Intercepted = System.Configuration.ConfigXmlDocument.CreateDocumentFragment(); } catch (Exception e) { exception_Intercepted = e; } Return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted)); }
/// <summary> /// renew all guids of xmlString /// </summary> /// <param name="xmlString"></param> /// <returns></returns> public string RefreshAllGuids(ref string xmlString) { System.Xml.XmlDocumentFragment fragdoc = xmlDoc.CreateDocumentFragment(); fragdoc.InnerXml = xmlString; System.Collections.IEnumerator ie = fragdoc.ChildNodes.GetEnumerator(); System.Collections.SortedList listGUID = new System.Collections.SortedList(); string strFirstGUID = null; xmlString = ""; while (ie.MoveNext()) { System.Xml.XmlNode node = (System.Xml.XmlNode)ie.Current; string OldGUID = GetAttributeByName(node, PazDocumentLegacy.TAG_GUID); string NewGUID = Guid.NewGuid().ToString(); string ParentGUID = GetAttributeByName(node, PazDocumentLegacy.TAG_PARENTGUID); if (strFirstGUID == null) { strFirstGUID = NewGUID; } listGUID.Add(OldGUID, NewGUID); if (listGUID.Contains(ParentGUID)) { SetAttributeByName(node, PazDocumentLegacy.TAG_PARENTGUID, (string)listGUID.GetByIndex(listGUID.IndexOfKey(ParentGUID))); } SetAttributeByName(node, PazDocumentLegacy.TAG_GUID, NewGUID); SetAttributeByName(node, PazDocumentLegacy.TAG_TIMESTAMP, DateTime.Now.Ticks.ToString()); xmlString += node.OuterXml; } return(strFirstGUID); }
Stream(System.Xml.XmlDocumentFragment doc) { m_dataObjs.Add(new Snoop.Data.ClassSeparator(typeof(System.Xml.XmlDocumentFragment))); // no data to display at this level }
internal XmlDocumentFragment(XmlDocument owner, SystemXmlDocumentFragment backingDocumentFragment) { _owner = owner; _backingDocumentFragment = backingDocumentFragment; }