J'ai téléchargé la dernière version de HtmlAgilityPack, où j'ai trouvé plusieurs dossiers comme Net20, Net40, etc. J'ai créé un nouveau projet et ajouté HtmlAgilityPack via add Reference .. (j'ai choisi le fichier .dll du dossier Net20) où ajouté en using HtmlAgilityPack;
. Alors maintenant, j'ai une erreur que ce symbole ne peut pas être utilisé dans une déclaration using.
Qu'est-ce qui ne va pas? Je suppose que j'ai fait quelque chose de mal avec la bibliothèque.
using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
int main()
{
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
// There are various options, set as needed
htmlDoc.OptionFixNestedTags=true;
// filePath is a path to a file containing the html
htmlDoc.Load(filePath);
// Use: htmlDoc.LoadXML(xmlString); to load from a string
// ParseErrors is an ArrayList containing any errors from the Load statement
if (htmlDoc.ParseErrors!=null && htmlDoc.ParseErrors.Count>0)
{
// Handle any parse errors as required
}
else
{
if (htmlDoc.DocumentNode != null)
{
HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body");
if (bodyNode != null)
{
// Do something with bodyNode
}
}
}
}
ajouter une référence en faisant un clic droit sur le dossier de référence / bin dans la solution de projet