 |
建站必读 |
 |
|
|
 |
|
 |
|
| |
| 当前位置:首页 -> 建站必读 -> .NET技术 |
|
XMLHelp 下 |
//接上回
/// <summary>
/// Create an Element under the given parent based on the name and value pair.
/// </summary>
public XmlElement CreateNodeElement(XmlNode parentNode, string sElementName, string sElementValue)
{
XmlElement newElem = null;
try
{
newElem = m_xmlDocument.CreateElement(sElementName);
newElem.InnerXml = Encode(sElementValue);
XmlDocument ownerDoc = parentNode.OwnerDocument;
if (ownerDoc != null)
{
parentNode.AppendChild(newElem);
}
else
{
XmlElement root = m_xmlDocument.DocumentElement;
root.AppendChild(newElem);
}
}
catch (Exception e)
{
HandleException ( e );
}
return newElem;
}
/// <summary>
/// Creates and adds a comment before the given node. If root node, or null,
/// the comment node is Appended to the tree.
/// </summary>
public XmlNode CreateComment(XmlNode insertAfterThisNode, string sVal)
{
if ( insertAfterThisNode == null )
return null;
XmlNode createdNode = null;
try
{
XmlComment commentNode = m_xmlDocument.CreateComment(Encode(sVal));
createdNode = insertAfterThisNode.AppendChild(commentNode);
}
catch ( Exception e )
{
HandleException ( e );
}
return createdNode;
}
public XmlNode CreateXmlDeclaration(string version, string encoding, string standalone)
{
XmlNode createdNode = null;
try
{
XmlDeclaration dec = m_xmlDocument.CreateXmlDeclaration(version, encoding, standalone);
createdNode = m_xmlDocument.PrependChild ( dec );
}
catch ( Exception e )
{
HandleException ( e );
}
return createdNode;
}
/// <summary>
/// Delete an XmlNode from the tree
/// </summary>
public bool DeleteNodeElement(XmlNode targetNode)
{
bool bResult = false;
try
{
XmlNode xmlNode = RootNode.RemoveChild(targetNode);
if (xmlNode != null)
bResult = true;
}
catch (Exception e)
{
HandleException ( e );
}
return bResult;
}
/// <summary>
&nb |
| |
|
| |
本站关键词: |
|
|
|
|
 |
|
 |
|