public static void Test4() { string HtmlCode = "<html><head></head><body><div><div>a</div><div><a><p>Test</p><p>Test2</p></a><p>1a</p></div><p>m</p><div><div><a><bold><p>Test</p><p>Test2</p></bold></a><p>1a</p></div><p>a</p></div><p>b</p><p>c</p><a>test</a></div></body></html>"; HTMLInterface TestInterface = new HTMLInterface(HtmlCode); TestInterface.GetFirstObject(); TestCallback CallbackClass = new TestCallback(); CallbackStore lCallbackStore = new CallbackStore(); lCallbackStore.AddCallback(new CallbackEntry("moredivs", CallbackClass.moredivs)); lCallbackStore.AddCallback(new CallbackEntry("moreps", CallbackClass.moreps)); lCallbackStore.AddCallback(new CallbackEntry("moremors", CallbackClass.moremors)); Xml XmlParse = new Xml(lCallbackStore); ParserPrimitives lPrimitive = XmlParse.ParseXMLFromFile("Test2.xml"); ObjectInterfacePrototipe tInterface = (ObjectInterfacePrototipe)TestInterface; lPrimitive.CheckRelations(ref tInterface, null, true); }
public static void Test2() { string HtmlCode = "<html><head></head><body><div><div>a</div><div>b</div><div>c</div><p>a</p><p>b</p><p>c</p><a>test</a></div></body></html>"; HTMLInterface TestInterface = new HTMLInterface(HtmlCode); TestInterface.GetFirstObject(); List<ObjectAttribute> RepresentAAttributes1 = new List<ObjectAttribute>(); RepresentAAttributes1.Add(new ObjectAttributeRegex("name", ".+")); //RepresentAAttributes1.Add(new ObjectAttributeRegex("innerText", "[a-z]")); ParserObject RepresentA1 = new ParserObject(RepresentAAttributes1); List<ObjectAttribute> RepresentPAttributes = new List<ObjectAttribute>(); RepresentPAttributes.Add(new ObjectAttributeRegex("name", "P")); RepresentPAttributes.Add(new ObjectAttributeRegex("innerText", "[a-z]")); ParserObject RepresentP = new ParserObject(RepresentPAttributes); List<ObjectAttribute> RepresentAAttributes2 = new List<ObjectAttribute>(); RepresentAAttributes2.Add(new ObjectAttributeString("name", "A")); RepresentAAttributes2.Add(new ObjectAttributeRegex("innerText", "[a-z]+")); ParserObject RepresentA2 = new ParserObject(RepresentAAttributes2); ObjectAttributeEvaluation evaluation = new ObjectAttributeEvaluation(EvaluationMode.Max, 1, 4); evaluation.AttributeName="ParseCount"; FunctionIO RelationMOREInput = new FunctionIO(); RelationMOREInput.AddFunctionParameter(evaluation); TestCallback CallbackClass = new TestCallback(); ParserObjectRelation RelationMORE = new ParserObjectRelation(); RelationMORE.SetRelationFunction(new RelationFunctionMORE(ref RelationMORE, RelationMOREInput)); RelationMORE.AddSubParserPrimitive(RepresentA1); RelationMORE.SetCallback(CallbackClass.Call); ParserObjectRelation RelationMORE2 = new ParserObjectRelation(); RelationMORE2.SetRelationFunction(new RelationFunctionMORE(ref RelationMORE2, RelationMOREInput)); RelationMORE2.AddSubParserPrimitive(RepresentP); RelationMORE2.SetCallback(CallbackClass.Call); List<ObjectAttribute> RepresentDIVAttributes = new List<ObjectAttribute>(); RepresentDIVAttributes.Add(new ObjectAttributeString("name", "DIV")); ParserObject RepresentDIV = new ParserObject(RepresentDIVAttributes); RepresentDIV.AddSubParserPrimitive(RelationMORE); RepresentDIV.AddSubParserPrimitive(RelationMORE2); RepresentDIV.AddSubParserPrimitive(RepresentA2); ObjectInterfacePrototipe tInterface = (ObjectInterfacePrototipe)TestInterface; FunctionIO Result = RepresentDIV.CheckRelations(ref tInterface, null, true); Result.GetType(); }