Esempio n. 1
0
        public static UrlPatternDatasource FromXmlNode(XmlNode node)
        {
            XmlAttribute attrFormat  = node.Attributes["format"];
            XmlAttribute attrExample = node.Attributes["example"];

            if (attrFormat == null && attrExample != null)
            {
                return(new UrlPatternDatasource(attrExample.Value));
            }

            string format            = attrFormat.Value;
            UrlPatternDatasource ret = new UrlPatternDatasource(format);

            int idx = 0;

            foreach (XmlNode sub in node.ChildNodes)
            {
                if (sub.Name.Equals("param", StringComparison.InvariantCultureIgnoreCase))
                {
                    ret.Params.Add(new ExtractParam
                    {
                        Index = idx,
                        Scope = ParamScope.arguments,
                        Name  = sub.Attributes["name"].Value
                    });
                    idx++;
                }
            }

            return(ret);
        }
Esempio n. 2
0
        internal void parseRuleDocument(XmlDocument xmlDoc)
        {
            XmlElement doc = xmlDoc.DocumentElement;

            foreach (XmlNode node in doc.ChildNodes)
            {
                ExtractNode extractNode = new ExtractNode(node, 1);
                NodeType    currentType = extractNode.GetExtractType();
                if (currentType == NodeType.Element)
                {
                    _extractNodes.Add(ExtractDataNode.ExtractNodeAll(node, extractNode.Deepth, this));
                }
                else if (currentType == NodeType.UrlPattern)
                {
                    EntryUrl = UrlPatternDatasource.FromXmlNode(node);
                }
                else if (currentType == NodeType.ScopeResult)
                {
                    DocumentResult = new ScopeResult(node, extractNode.Deepth);
                }
            }
        }