Parsing XHTML 1.1 à l'aide du XML erreur que je ne comprends pas
Salut,
J'ai besoin de parser une partie d'un document HTML.
Comme j'aimerais utiliser les XPath, j'ai procédé comme suit :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
string htmlToParse = @"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.1//EN"" ""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"">";
htmlToParse += "\n";
htmlToParse += @"<html xmlns=""http://www.w3.org/1999/xhtml"">";
htmlToParse += "\n";
htmlToParse += @"<head>";
htmlToParse += "\n";
htmlToParse += @"<title>none</title>";
htmlToParse += "\n";
htmlToParse += @"</head>";
htmlToParse += @"<body>";
htmlToParse += "\n";
htmlToParse += model.ModelToEdit.NewContent;
htmlToParse += "\n";
htmlToParse += @"</body>";
htmlToParse += "\n";
htmlToParse += @"</html>";
Hierarchy dbHierarchyParent = _context.Hierarchy_Rep.Query(x => x.Id == -ContentId).FirstOrDefault();
XmlDocument oXmlDocument = new XmlDocument();
oXmlDocument.PreserveWhitespace = true;
oXmlDocument.XmlResolver = new INNOVACALL.Framework.Common.XMLTools.HtmlResolver();
XmlNamespaceManager ns = new XmlNamespaceManager(oXmlDocument.NameTable);
ns.AddNamespace("html", "http://www.w3.org/1999/xhtml");
oXmlDocument.LoadXml(htmlToParse);
XmlNodeList nodes = oXmlDocument.SelectNodes("//div[@class='mceEditable']", ns);
foreach(XmlNode node in nodes){
string nodeId = node.Attributes["id"].ToString();
} |
Lorsque j’exécute le code, j'obtiens l'erreur :
Citation:
Impossible de résoudre le sous-ensemble DTD externe - ID public = '-//W3C//DTD XHTML 1.1//EN', ID système = 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'.
J'ai fais le test, j'ai saisi l'adresse dans un navigateur et je tombe bien sur le DTD du W3C.
Quelqu'un pourrait-il m'expliquer le problème ?
D'avance merci
Laurent