Main
namespace ReaderXML
{
class Program
{
static void Main(string[] args)
{
var website = LeitorDeXML("http://SITE ORIGEM/").ToArray();
var total = website.Count();
for (int i = 1; i < total; i++)
{
Postagem(website[i]);
}
}
Method for blog post
private static void Postagem(string website)
{
try
{
//LINK,USER,SENHA WP
string link = "http://SITE NOVO";
string username = "user wp";
string password = "senha wp";
//Leitura do HTML
HtmlWeb web = new HtmlWeb();
HtmlDocument resultat = web.Load(website);
//Separar TITULO e CONTEUDO
string titulopost = resultat.DocumentNode.SelectNodes("//*[contains(@class,'entry-title')]")[0].InnerHtml;
string conteudo = resultat.DocumentNode.SelectNodes("//*[contains(@class,'entry-content')]")[0].InnerHtml; //ERRO AQUI
//Entrada no wp
var wp = new WordPressWrapper(link + "/xmlrpc.php", username, password);
var post = new Post();
//Categoria -- Não está funcionando ainda a parte da criação da categoria
int website_corpo = 25;
string categoria = website.Substring(website_corpo);
int indexof_barra = categoria.IndexOf("/");
int comeco_cat = 0;
string categoria_f = categoria.Substring(comeco_cat, indexof_barra);
//Data
post.DateCreated = DateTime.Today.AddHours(0);
//Postagem
post.Title = titulopost;
post.Body = conteudo;
wp.NewPost(post, true);
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
Console.ReadKey();
}
}
}
}
The "ReadModel" method reads a declared sitemap in MAIN and returns me the latest urls.
The problem is that when I pass this url as a parameter, at the time it takes the "content string" it goes no further.
Give the following error:
Error: System.NullReferenceException: Object reference not set to an instance of an object