本文整理汇总了C#中System.Xml.XmlNode.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.GetType方法的具体用法?C# XmlNode.GetType怎么用?C# XmlNode.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.GetType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAndAddElement
public static XmlElement CreateAndAddElement(XmlNode parentNode, string childName)
{
XmlElement node;
if (parentNode.GetType() == typeof(XmlDocument))
node = ((XmlDocument)parentNode).CreateElement(childName);
else
node = parentNode.OwnerDocument.CreateElement(childName);
parentNode.AppendChild(node);
return node;
}
示例2: GetAttribute
/// <summary>
///
/// </summary>
/// <param name="node"></param>
/// <param name="name"></param>
/// <param name="canNull"></param>
/// <returns></returns>
public static string GetAttribute(XmlNode node, string name, bool canNull)
{
if (node == null)
throw new ArgumentNullException("node");
XmlElement e = node as XmlElement;
if (e == null)
throw new ArgumentException("node must be XmlElement, but was " + node.GetType().Name);
return GetAttribute(e, name, canNull);
}
示例3: CreateAndAddAttribute
public static XmlAttribute CreateAndAddAttribute(XmlNode parentNode, string attributeName, string innerText)
{
XmlAttribute node;
if (parentNode.GetType() == typeof(XmlDocument))
node = ((XmlDocument)parentNode).CreateAttribute(attributeName);
else
node = parentNode.OwnerDocument.CreateAttribute(attributeName);
parentNode.Attributes.Append(node);
if (innerText != null)
node.InnerText = innerText;
return node;
}
示例4: AppendElement
public static XmlNode AppendElement( XmlNode node, string newElementName, string innerValue )
{
XmlNode oNode ;
if ( node.GetType() == typeof(XmlDocument) )
oNode = node.AppendChild( ((XmlDocument)node).CreateElement( newElementName ) ) ;
else
oNode = node.AppendChild( node.OwnerDocument.CreateElement( newElementName ) ) ;
if ( innerValue != null )
oNode.AppendChild( node.OwnerDocument.CreateTextNode( innerValue ) ) ;
return oNode ;
}
示例5: CreateAndAddElementWithValue
public static XmlElement CreateAndAddElementWithValue(XmlNode parentNode, string childName, string val)
{
XmlElement node;
XmlDocument owner = null;
if (parentNode.GetType() == typeof(XmlDocument))
owner = (XmlDocument)parentNode;
else
owner = parentNode.OwnerDocument;
node = owner.CreateElement(childName);
parentNode.AppendChild(node);
XmlAttribute attr = owner.CreateAttribute("value");
attr.InnerText = val;
node.Attributes.Append(attr);
return node;
}
示例6: CreateXmlNode
/// <summary>
/// 创建一个XmlNode并添加到文档
/// </summary>
/// <param name="clsParentNode">父节点</param>
/// <param name="szNodeName">结点名称</param>
/// <returns>XmlNode</returns>
private static XmlNode CreateXmlNode(XmlNode clsParentNode, string szNodeName)
{
try
{
XmlDocument clsXmlDoc = null;
if (clsParentNode.GetType() != typeof(XmlDocument))
clsXmlDoc = clsParentNode.OwnerDocument;
else
clsXmlDoc = clsParentNode as XmlDocument;
XmlNode clsXmlNode = clsXmlDoc.CreateNode(XmlNodeType.Element, szNodeName, string.Empty);
if (clsParentNode.GetType() == typeof(XmlDocument))
{
clsXmlDoc.LastChild.AppendChild(clsXmlNode);
}
else
{
clsParentNode.AppendChild(clsXmlNode);
}
return clsXmlNode;
}
catch
{
return null;
}
}
示例7: IdentifyNode
private string IdentifyNode(XmlNode node)
{
if (node == null)
return "<null>";
return String.Format(TypeConverterHelper.InvariantEnglishUS, "{0} ({1})",
node.GetType().Name, node.Name);
}
示例8: FromXml
//FROM XML
public void FromXml(XmlNode item)
{
Attributes.Clear();
Name = "";
Body = "";
IsCommentary = false;
switch (item.GetType().ToString())
{
case "System.Xml.XmlComment":
IsCommentary = true;
Name = "Commentary";
Body = item.InnerText;
break;
case "System.Xml.XmlElement":
Name = item.Name;
foreach (XmlAttribute att in item.Attributes)
SetAttribute(att.Name, att.Value);
if (!String.IsNullOrEmpty(item.InnerText))
Body = item.InnerText;
break;
}
SourceXML = string.IsNullOrEmpty(SourceXML) ? item.OuterXml : SourceXML;
}
示例9: AddSimpleNode
//.........这里部分代码省略.........
int clid = m_cache.GetClassOfObject(hvoT);
if (clid == (int)CellarModuleDefns.kclidStText) // if clid is an sttext clid
{
// Test if the StText has only one paragraph
int cpara = m_cache.GetVectorSize(hvoT, (int)CellarModuleDefns.kflidStText_Paragraphs);
if (cpara == 1)
{
// Tests if paragraph is empty
int hvoPara = m_cache.GetVectorItem(hvoT, (int)CellarModuleDefns.kflidStText_Paragraphs, 0);
if (hvoPara == 0)
return NodeTestResult.kntrNothing;
ITsString tss = m_cache.GetTsStringProperty(hvoPara, (int)CellarModuleDefns.kflidStTxtPara_Contents);
if (tss == null || tss.Length == 0)
return NodeTestResult.kntrNothing;
}
}
break;
case FieldType.kcptOwningCollection:
case FieldType.kcptOwningSequence:
case FieldType.kcptReferenceCollection:
case FieldType.kcptReferenceSequence:
if (m_cache.MainCacheAccessor.get_VecSize(obj.Hvo, flid) == 0)
return NodeTestResult.kntrNothing;
break;
}
}
else if (editor == null)
{
// may be a summary node for a sequence or atomic node. Suppress it as well as the prop.
XmlNode child = null;
int cnodes = 0;
foreach (XmlNode n in node.ChildNodes)
{
if (node.GetType() == typeof(XmlComment))
continue;
cnodes++;
if (cnodes > 1)
break;
child = n;
}
if (cnodes == 1) // exactly one non-comment child
{
int flidChild = GetFlidFromNode(child, obj);
// If it's an obj or seq node and the property is empty, we'll show nothing.
if (flidChild != 0 && child.Name == "seq" &&
m_cache.MainCacheAccessor.get_VecSize(obj.Hvo, flidChild) == 0)
{
return NodeTestResult.kntrNothing;
}
if (flidChild != 0 && child.Name == "obj" &&
m_cache.MainCacheAccessor.get_ObjectProp(obj.Hvo, flidChild) == 0)
{
return NodeTestResult.kntrNothing;
}
}
}
}
if (fTestOnly)
return NodeTestResult.kntrSomething; // slices always produce something.
path.Add(node);
Slice slice = GetMatchingSlice(path, reuseMap);
if (slice == null)
{
slice = SliceFactory.Create(m_cache, editor, flid, node, obj, StringTbl, PersistenceProvder, m_mediator, caller);
if (slice == null)