本文整理汇总了C#中INode.getNodeType方法的典型用法代码示例。如果您正苦于以下问题:C# INode.getNodeType方法的具体用法?C# INode.getNodeType怎么用?C# INode.getNodeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INode
的用法示例。
在下文中一共展示了INode.getNodeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: collectElements
private void collectElements(INode c, string s, IList<IElement> nodes)
{
if(c.getNodeType()==NodeType.ELEMENT_NODE){
Element e=(Element)c;
if(s==null || e.getLocalName().Equals(s)){
nodes.Add(e);
}
}
foreach(var node in c.getChildNodes()){
collectElements(node,s,nodes);
}
}
示例2: collectElementsHtml
private void collectElementsHtml(INode c, string s,
string sLowercase, IList<IElement> nodes)
{
if(c.getNodeType()==NodeType.ELEMENT_NODE){
Element e=(Element)c;
if(s==null){
nodes.Add(e);
} else if(HtmlParser.HTML_NAMESPACE.Equals(e.getNamespaceURI()) &&
e.getLocalName().Equals(sLowercase)){
nodes.Add(e);
} else if(e.getLocalName().Equals(s)){
nodes.Add(e);
}
}
foreach(var node in c.getChildNodes()){
collectElements(node,s,nodes);
}
}
示例3: fragmentSerializeInner
private void fragmentSerializeInner(
INode current, StringBuilder builder)
{
if(current.getNodeType()==NodeType.ELEMENT_NODE){
IElement e=((IElement)current);
string tagname=e.getTagName();
string namespaceURI=e.getNamespaceURI();
if(HtmlParser.HTML_NAMESPACE.Equals(namespaceURI) ||
HtmlParser.SVG_NAMESPACE.Equals(namespaceURI) ||
HtmlParser.MATHML_NAMESPACE.Equals(namespaceURI)){
tagname=e.getLocalName();
}
builder.Append('<');
builder.Append(tagname);
foreach(var attr in e.getAttributes()){
namespaceURI=attr.getNamespaceURI();
builder.Append(' ');
if(namespaceURI==null || namespaceURI.Length==0){
builder.Append(attr.getLocalName());
} else if(namespaceURI.Equals(HtmlParser.XML_NAMESPACE)){
builder.Append("xml:");
builder.Append(attr.getLocalName());
} else if(namespaceURI.Equals(
"http://www.w3.org/2000/xmlns/")){
if(!"xmlns".Equals(attr.getLocalName())) {
builder.Append("xmlns:");
}
builder.Append(attr.getLocalName());
} else if(namespaceURI.Equals(HtmlParser.XLINK_NAMESPACE)){
builder.Append("xlink:");
builder.Append(attr.getLocalName());
} else {
builder.Append(attr.getName());
}
builder.Append("=\"");
string value=attr.getValue();
for(int i=0;i<value.Length;i++){
char c=value[i];
if(c=='&') {
builder.Append("&");
} else if(c==0xa0) {
builder.Append(" ");
} else if(c=='"') {
builder.Append(""");
} else {
builder.Append(c);
}
}
builder.Append('"');
}
builder.Append('>');
if(HtmlParser.HTML_NAMESPACE.Equals(namespaceURI)){
string localName=e.getLocalName();
if("area".Equals(localName) ||
"base".Equals(localName) ||
"basefont".Equals(localName) ||
"bgsound".Equals(localName) ||
"br".Equals(localName) ||
"col".Equals(localName) ||
"embed".Equals(localName) ||
"frame".Equals(localName) ||
"hr".Equals(localName) ||
"img".Equals(localName) ||
"input".Equals(localName) ||
"keygen".Equals(localName) ||
"link".Equals(localName) ||
"menuitem".Equals(localName) ||
"meta".Equals(localName) ||
"param".Equals(localName) ||
"source".Equals(localName) ||
"track".Equals(localName) ||
"wbr".Equals(localName))
return;
if("pre".Equals(localName) ||
"textarea".Equals(localName) ||
"listing".Equals(localName)){
foreach(var node in e.getChildNodes()){
if(node.getNodeType()==NodeType.TEXT_NODE &&
((IText)node).getData().Length>0 &&
((IText)node).getData()[0]=='\n'){
builder.Append('\n');
}
}
}
}
// Recurse
foreach(var child in e.getChildNodes()){
fragmentSerializeInner(child,builder);
}
builder.Append("</");
builder.Append(tagname);
builder.Append(">");
} else if(current.getNodeType()==NodeType.TEXT_NODE){
INode parent=current.getParentNode();
if(parent is IElement &&
HtmlParser.HTML_NAMESPACE.Equals(((IElement)parent).getNamespaceURI())){
string localName=((IElement)parent).getLocalName();
if("script".Equals(localName) ||
"style".Equals(localName) ||
"script".Equals(localName) ||
//.........这里部分代码省略.........