当前位置: 首页>>代码示例>>C#>>正文


C# IElement.getChildNodes方法代码示例

本文整理汇总了C#中IElement.getChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C# IElement.getChildNodes方法的具体用法?C# IElement.getChildNodes怎么用?C# IElement.getChildNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IElement的用法示例。


在下文中一共展示了IElement.getChildNodes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: process


//.........这里部分代码省略.........
     RDFTerm currentProperty=null;
     foreach(var pred in preds){
       string iri=getCurie(pred,
       iriMapLocal);
       if(iri!=null){
     //Console.WriteLine("iri=[%s]",iri);
     currentProperty=null;
     if(datatypeValue!=null && datatypeValue.Length>0 &&
     !datatypeValue.Equals(RDF_XMLLITERAL)){
       string literal=content;
       if(literal==null) {
     literal=getTextNodeText(node);
       }
       currentProperty=RDFTerm.fromTypedString(literal,datatypeValue);
     } else if(node.getAttribute("content")!=null ||
     !hasNonTextChildNodes(node) ||
     (datatypeValue!=null && datatypeValue.Length==0)){
       string literal=node.getAttribute("content");
       if(literal==null) {
     literal=getTextNodeText(node);
       }
       currentProperty=(!string.IsNullOrEmpty(localLanguage)) ?
       RDFTerm.fromLangString(literal, localLanguage) :
         RDFTerm.fromTypedString(literal);
     } else if(hasNonTextChildNodes(node) &&
     (datatypeValue==null || datatypeValue.Equals(RDF_XMLLITERAL))){
       // XML literal
       recurse=false;
       if(datatypeValue==null) {
     datatypeValue=RDF_XMLLITERAL;
       }
       try {
     string literal=ExclusiveCanonicalXML.canonicalize(node,
         false, namespacesLocal);
     currentProperty=RDFTerm.fromTypedString(literal,datatypeValue);
       } catch(ArgumentException){
     // failure to canonicalize
       }
     }
     #if DEBUG
     if(!(newSubject!=null))throw new InvalidOperationException("doesn't satisfy newSubject!=null");
     #endif
     outputGraph.Add(new RDFTriple(
     newSubject,
     RDFTerm.fromIRI(iri),currentProperty
     ));
       }
     }
     // Step 10
     if(!skipElement && newSubject!=null){
       foreach(var triple in context.incompleteTriples){
     if(triple.direction==RDFa.ChainingDirection.Forward){
       outputGraph.Add(new RDFTriple(
       context.parentSubject,
       triple.predicate,
       newSubject));
     } else {
       outputGraph.Add(new RDFTriple(
       newSubject,triple.predicate,
       context.parentSubject));
     }
       }
     }
     // Step 13
     if(recurse){
       foreach(var childNode in node.getChildNodes()){
     IElement childElement;
     RDFa.EvalContext oldContext=context;
     if(childNode is IElement){
       childElement=((IElement)childNode);
       //Console.WriteLine("skip=%s vocab=%s local=%s",
       //  skipElement,context.defaultVocab,
       //localDefaultVocab);
       if(skipElement){
     RDFa.EvalContext ec=oldContext.copy();
     ec.language=localLanguage;
     ec.iriMap=iriMapLocal;
     ec.namespaces=namespacesLocal;
     context=ec;
     process(childElement,false);
       } else {
     RDFa.EvalContext ec=new RDFa.EvalContext();
     ec.baseURI=oldContext.baseURI;
     ec.iriMap=iriMapLocal;
     ec.namespaces=namespacesLocal;
     ec.incompleteTriples=incompleteTriplesLocal;
     ec.parentSubject=((newSubject==null) ? oldContext.parentSubject :
       newSubject);
     ec.parentObject=((currentObject==null) ?
         ((newSubject==null) ? oldContext.parentSubject :
           newSubject) : currentObject);
     ec.language=localLanguage;
     context=ec;
     process(childElement,false);
       }
     }
     context=oldContext;
       }
     }
 }
开发者ID:peteroupc,项目名称:HtmlParserCSharp,代码行数:101,代码来源:RDFa1.cs

示例2: propertyWalk

   private static void propertyWalk(IElement root,
 JSONObject properties, JSONArray children)
   {
       string[] className=getClassNames(root);
       if(className.Length>0){
         IList<string> types=new List<string>();
         bool hasProperties=false;
         foreach(var cls in className){
       if(cls.StartsWith("p-",StringComparison.Ordinal) && properties!=null){
         hasProperties=true;
       } else if(cls.StartsWith("u-",StringComparison.Ordinal) && properties!=null){
         hasProperties=true;
       } else if(cls.StartsWith("dt-",StringComparison.Ordinal) && properties!=null){
         hasProperties=true;
       } else if(cls.StartsWith("e-",StringComparison.Ordinal) && properties!=null){
         hasProperties=true;
       } else if(cls.StartsWith("h-",StringComparison.Ordinal)){
         types.Add(cls);
       }
         }
         if(types.Count==0 && hasProperties){
       // has properties and isn't a microformat
       // root
       foreach(var cls in className){
         if(cls.StartsWith("p-",StringComparison.Ordinal)){
       string value=getPValue(root);
       if(!StringUtility.isNullOrSpaces(value)) {
         accumulateValue(properties,cls.Substring(2),value);
       }
         } else if(cls.StartsWith("u-",StringComparison.Ordinal)){
       accumulateValue(properties,cls.Substring(2),
           getUValue(root));
         } else if(cls.StartsWith("dt-",StringComparison.Ordinal)){
       accumulateValue(properties,cls.Substring(3),
           getDTValue(root,getLastKnownTime(properties)));
         } else if(cls.StartsWith("e-",StringComparison.Ordinal)){
       accumulateValue(properties,cls.Substring(2),
           getEValue(root));
         }
       }
         } else if(types.Count>0){
       // this is a child microformat
       // with no properties
       JSONObject obj=new JSONObject();
       obj.put("type", new JSONArray(types));
       // for holding child elements with
       // properties
       JSONObject subProperties=new JSONObject();
       // for holding child microformats with no
       // property class
       JSONArray subChildren=new JSONArray();
       foreach(var child in root.getChildNodes()){
         if(child is IElement) {
       propertyWalk((IElement)child,
           subProperties,subChildren);
         }
       }
       if(subChildren.Length>0){
         obj.put("children", subChildren);
       }
       if(types.Count>0){
         // we imply missing properties here
         // Imply p-name and p-url
         if(!implyForLink(root,subProperties)){
       if(hasSingleChildElementNamed(root,"a")){
         implyForLink(getFirstChildElement(root),subProperties);
       } else {
         string pvalue=getPValue(root);
         if(!StringUtility.isNullOrSpaces(pvalue)) {
           setValueIfAbsent(subProperties,"name", pvalue);
         }
       }
         }
         // Also imply u-photo
         if(StringUtility.toLowerCaseAscii(root.getLocalName()).Equals("img") &&
         root.getAttribute("src")!=null){
       setValueIfAbsent(subProperties,"photo", getUValue(root));
         }
         if(!subProperties.has("photo")){
       IList<IElement> images=root.getElementsByTagName("img");
       // If there is only one descendant image, imply
       // u-photo
       if(images.Count==1){
         setValueIfAbsent(subProperties,"photo",
             getUValue(images[0]));
       }
         }
       }
       obj.put("properties", subProperties);
       if(hasProperties){
         foreach(var cls in className){
       if(cls.StartsWith("p-",StringComparison.Ordinal)){ // property
         JSONObject clone=copyJson(obj);
         clone.put("value",getPValue(root));
         accumulateValue(properties,cls.Substring(2),clone);
       } else if(cls.StartsWith("u-",StringComparison.Ordinal)){ // URL
         JSONObject clone=copyJson(obj);
         clone.put("value",getUValue(root));
         accumulateValue(properties,cls.Substring(2),clone);
       } else if(cls.StartsWith("dt-",StringComparison.Ordinal)){ // date/time
//.........这里部分代码省略.........
开发者ID:peteroupc,项目名称:HtmlParserCSharp,代码行数:101,代码来源:Microformats.cs

示例3: miniRdfXml

 // Processes a subset of RDF/XML metadata
 // Doesn't implement RDF/XML completely
 private void miniRdfXml(IElement node, RDFa.EvalContext context, RDFTerm subject)
 {
     string language=context.language;
     foreach(var child in node.getChildNodes()){
       IElement childElement=(child is IElement) ?
       ((IElement)child) : null;
       if(childElement==null) {
     continue;
       }
       if(node.getAttribute("xml:lang")!=null){
     language=node.getAttribute("xml:lang");
       } else {
     language=context.language;
       }
       if(childElement.getLocalName().Equals("Description") &&
       RDF_NAMESPACE.Equals(childElement.getNamespaceURI())){
     RDFTerm about=relativeResolve(childElement.getAttributeNS(RDF_NAMESPACE,"about"));
     //Console.WriteLine("about=%s [%s]",about,childElement.getAttribute("about"));
     if(about==null){
       about=subject;
       if(about==null) {
         continue;
       }
     }
     foreach(var child2 in child.getChildNodes()){
       IElement childElement2=
           ((child2 is IElement) ?
               ((IElement)child2) : null);
       if(childElement2==null) {
         continue;
       }
       miniRdfXmlChild(childElement2,about,language);
     }
       } else if(RDF_NAMESPACE.Equals(childElement.getNamespaceURI()))
     throw new NotSupportedException();
     }
 }
开发者ID:peteroupc,项目名称:HtmlParserCSharp,代码行数:39,代码来源:RDFa1.cs

示例4: relWalk

   private static void relWalk(IElement root,
 JSONObject properties)
   {
       string[] className=getRelNames(root);
       if(className.Length>0){
         string href=getHref(root);
         if(!StringUtility.isNullOrSpaces(href)){
       foreach(var cls in className){
         accumulateValue(properties,cls,href);
       }
         }
       }
       foreach(var child in root.getChildNodes()){
         if(child is IElement) {
       relWalk((IElement)child,properties);
         }
       }
   }
开发者ID:peteroupc,项目名称:HtmlParserCSharp,代码行数:18,代码来源:Microformats.cs


注:本文中的IElement.getChildNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。