How to Check for Parsed Text on CC?

loxllxol

Client
Регистрация
21.12.2011
Сообщения
13
Благодарностей
0
Баллы
0
What's the right way to CHECK FOR PARSED TEXT in CC?

Below is what was converted automatically from a working XML file.

PHP:
			// Checking parsed text
			tb = instance.MainTab;
			if ((tb.IsVoid) || (tb.IsNull)) return -1;
			if (tb.IsBusy) tb.WaitDownloading();
			var attribute = tb.PageText;
			return 0;
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113
It can't be converted definitely to c# from template, that's why you should customize this step.
Just add a few line of code:

[xcode=c#]
if(attribute.Contains("Text for check here"))
{
//do something
}
else
{
//do something
}
[/code]
 

loxllxol

Client
Регистрация
21.12.2011
Сообщения
13
Благодарностей
0
Баллы
0
Is the below code correct?

PHP:
// Checking parsed text
            tb = instance.MainTab;
            if ((tb.IsVoid) || (tb.IsNull)) return -1;
            if (tb.IsBusy) tb.WaitDownloading();
            var attribute = tb.PageText;
			if(attribute.Contains("Hotmail Highlights"))
				{
					// ADDING LOGIN AND PASSWORD TO FILE
					instance.RiseMacros("File.AppendString", new [] {"C:\\Users\\Alfie\\Dropbox\\Zenno Data\\Assets\\Emails\\hotmail-presetup.txt", login + ":" + password, "true" });
				}
				else
				{
				     //DO SOMETHING ELSE
				}
 

loxllxol

Client
Регистрация
21.12.2011
Сообщения
13
Благодарностей
0
Баллы
0
^^ HB, please tell me if the above code is correct for CHECKING FOR TEXT PRESENCE.

the problem with the line:

PHP:
 var attribute = tb.PageText;
is the value is <null> while debugging.
 

smol84

Client
Регистрация
06.01.2012
Сообщения
30
Благодарностей
2
Баллы
0
Thats because your above code is getting the text of the entire page that your on (your not actually on a page in the code you pasted)

You need to navigate to a page, direct the code to what you want to search - search it - and do something
or
navigate to a page, get the dom or text or html, regex search it
(you are using contains here which is a c# class for HTML elements, I've noticed this does not behave the same as the custom zenno namespaces we have to use, i find this causes errors and try to avoid it)

heres something i use:

Код:
//save DOM
string input = tb.DomText;
									//regular expression to use
									string regular_expression = make[a] + @".*(?=whatever)";
									// create a new Regex object for regular expression
									Regex rgx = new Regex(regular_expression, RegexOptions.Compiled | RegexOptions.IgnoreCase);
									// collection of all matches
									MatchCollection all = rgx.Matches(input);
									
									foreach (Match m in all) 
									{	//write to file
										WriteFile.WriteToFile("bla"); 
									}
 

mat123pl

Client
Регистрация
20.05.2011
Сообщения
13
Благодарностей
0
Баллы
1
how to get this result ...?

Код:
if(attribute.Contains("Text for check here"))
 {
       //go to step2
}
else
{
       //go to step3
}
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)