public string GetTextString() { var ptr = XmlSDK.RapidXmlA_GetXMLString(mCoreObject); var cstr = new CStringObject(ptr); return(cstr.Text); }
public XmlNode FindNode(string name) { unsafe { if (CoreObject.Pointer == IntPtr.Zero) { return(null); } var node = XmlSDK.RapidXmlNodeA_first_node(CoreObject, name); while (node.Pointer != IntPtr.Zero) { int pNeedFreeStr = 0; var strPtr = XmlSDK.RapidXmlNodeA_name(node, ref pNeedFreeStr); var nodeName = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strPtr); if (pNeedFreeStr == 1) { XmlSDK.RapidXmlNodeA_FreeString(strPtr); } if (name == nodeName) { var nd = new XmlNode(node); nd.mHolder = mHolder; return(nd); } node = XmlSDK.RapidXmlNodeA_next_sibling(node); } return(null); } }
public void Dispose() { if (CoreObject.Pointer != IntPtr.Zero) { XmlSDK.RapidXmlA_Delete(CoreObject); mCoreObject.Pointer = IntPtr.Zero; } }
public XmlAttrib AddAttrib(string name) { unsafe { var attr = XmlSDK.RapidXmlNodeA_allocate_attribute(mHolder.CoreObject, name, ""); XmlSDK.RapidXmlNodeA_append_attribute(CoreObject, attr); return(new XmlAttrib(attr)); } }
public static void GetXMLStringFromNode(ref string xmlStr, XmlNode node) { unsafe { var str = XmlSDK.RapidXmlNodeA_GetStringFromNode(node.CoreObject); xmlStr = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(str); XmlSDK.RapidXmlNodeA_FreeString(str); } }
public static void SaveXML(System.String file, XmlHolder node, bool bClearStrPtr = true) { // 计算绝对路径 var fileName = CEngine.Instance.FileManager._GetAbsPathFromRelativePath(file); unsafe { XmlSDK.RapidXmlA_SaveXML(node.CoreObject, fileName); } }
public static XmlHolder NewXMLHolder(System.String name, System.String value) { unsafe { var xmlHolder = new XmlHolder(); xmlHolder.mCoreObject = XmlSDK.RapidXmlA_NewXmlHolder(); var root = XmlSDK.RapidXmlNodeA_allocate_node(xmlHolder.CoreObject, name, ""); XmlSDK.RapidXmlA_append_node(xmlHolder.CoreObject, root); return(xmlHolder); } }
public XmlAttrib AddAttrib(string name, string value) { unsafe { //if (name == null) // name = ""; //if (value == null) // value = ""; var attr = XmlSDK.RapidXmlNodeA_allocate_attribute(mHolder.CoreObject, name, value); XmlSDK.RapidXmlNodeA_append_attribute(CoreObject, attr); return(new XmlAttrib(attr)); } }
public List <XmlNode> FindNodes(string name, FNodeFinderCondition condition = null) { unsafe { List <XmlNode> nodeList = new List <XmlNode>(); if (mCoreObject.Pointer == IntPtr.Zero) { return(nodeList); } XmlNode.NativePointer node = XmlSDK.RapidXmlNodeA_first_node(mCoreObject, name); while (mCoreObject.Pointer != IntPtr.Zero && node.Pointer != IntPtr.Zero) { int pNeedFreeStr = 0; var strPtr = XmlSDK.RapidXmlNodeA_name(node, ref pNeedFreeStr); var nodeName = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(strPtr); if (pNeedFreeStr == 1) { XmlSDK.RapidXmlNodeA_FreeString(strPtr); } if (name == nodeName) { XmlNode nd = new XmlNode(node); nd.mHolder = mHolder; bool bCancel = false; if (condition != null) { if (condition(nd, ref bCancel)) { nodeList.Add(nd); } } else { nodeList.Add(nd); } if (bCancel) { break; } } node = XmlSDK.RapidXmlNodeA_next_sibling(node); } return(nodeList); } }
public static XmlHolder ParseXML(System.String xmlString) { var pHolder = XmlSDK.RapidXmlA_ParseXML(xmlString); if (pHolder.Pointer == IntPtr.Zero) { return(null); } var xmlHolder = new XmlHolder(); xmlHolder.mCoreObject = pHolder; return(xmlHolder); }
public XmlAttrib FindAttrib(string name) { unsafe { if (CoreObject.Pointer == IntPtr.Zero) { return(null); } var attr = XmlSDK.RapidXmlNodeA_first_attribute(CoreObject, name); if (attr.Pointer == IntPtr.Zero) { return(null); } return(new XmlAttrib(attr)); } }
public static XmlHolder LoadXML(System.String file) { unsafe { // 计算绝对路径 file = CEngine.Instance.FileManager._GetAbsPathFromRelativePath(file); //IntPtr strPtr = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(file); //file = file.ToLower(); var pHolder = XmlSDK.RapidXml_LoadFileA(file); if (pHolder.Pointer == IntPtr.Zero) { return(null); } var holder = new XmlHolder(); holder.mCoreObject = pHolder; return(holder); } }
public List <XmlAttrib> GetAttribs() { unsafe { var attrList = new List <XmlAttrib>(); if (CoreObject.Pointer == IntPtr.Zero) { return(attrList); } for (var attr = XmlSDK.RapidXmlNodeA_first_attribute(CoreObject, null); attr.Pointer != IntPtr.Zero; attr = XmlSDK.RapidXmlAttribA_next_sibling(attr)) { var nd = new XmlAttrib(attr); attrList.Add(nd); } return(attrList); } }
public List <XmlNode> GetNodes() { unsafe { var nodeList = new List <XmlNode>(); if (CoreObject.Pointer == IntPtr.Zero) { return(nodeList); } for (var node = XmlSDK.RapidXmlNodeA_first_node(CoreObject, null); node.Pointer != IntPtr.Zero; node = XmlSDK.RapidXmlNodeA_next_sibling(node)) { var nd = new XmlNode(node); nd.mHolder = mHolder; nodeList.Add(nd); } return(nodeList); } }
public XmlNode AddNode(string name, string value, XmlHolder holder) { unsafe { if (CoreObject.Pointer == IntPtr.Zero) { return(null); } var node = XmlSDK.RapidXmlNodeA_allocate_node(holder.CoreObject, name, value); XmlSDK.RapidXmlNodeA_append_node(CoreObject, node); var result = new XmlNode(node); if (holder == null) { result.mHolder = mHolder; } else { result.mHolder = holder; } return(result); } }
public XmlNode FindNode(FOnFindNode onFind) { unsafe { if (CoreObject.Pointer == IntPtr.Zero) { return(null); } var node = XmlSDK.RapidXmlNodeA_first_node(CoreObject, null); while (node.Pointer != IntPtr.Zero) { var nd = new XmlNode(node); nd.mHolder = mHolder; if (onFind(nd)) { return(nd); } node = XmlSDK.RapidXmlNodeA_next_sibling(node); } return(null); } }
public void RemoveNode(XmlNode node) { XmlSDK.RapidXmlNodeA_remove_node(CoreObject, node.CoreObject); }
public void RemoveAttrib(XmlAttrib attr) { XmlSDK.RapidXmlNodeA_remove_attribute(CoreObject, attr.CoreObject); }