J'ouvre un fichier XML en utilisant .NET XmlReader et en enregistrant le fichier dans un autre nom de fichier et il semble que la déclaration DOCTYPE change entre les deux fichiers. Alors que le fichier nouvellement enregistré est toujours valide en XML, je me demandais pourquoi il insistait pour changer les tags d'origine..NET XmlDocument: pourquoi les modifications DOCTYPE après l'enregistrement?
Dim oXmlSettings As Xml.XmlReaderSettings = New Xml.XmlReaderSettings()
oXmlSettings.XmlResolver = Nothing
oXmlSettings.CheckCharacters = False
oXmlSettings.ProhibitDtd = False
oXmlSettings.IgnoreWhitespace = True
Dim oXmlDoc As XmlReader = XmlReader.Create(pathToOriginalXml, oXmlSettings)
Dim oDoc As XmlDocument = New XmlDocument()
oDoc.Load(oXmlDoc)
oDoc.Save(pathToNewXml)
qui suit (dans le document original):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
devient (notez le caractère à la fin []):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd"[]>
+1 parce que cela fonctionne. Cependant, mon format HTML/XML a été formaté de façon funky et difficile à lire. Pour une autre option, cette réponse a fonctionné sans se soucier du format du document: http://stackoverflow.com/a/16451790/279516. –