0
xmlファイルを読み込もうとしていますが、読み込み中に#textを取得しています。私はすべての空白を削除しましたが、この#textは今後も続けられます。解決策は何ですか?C#を使用して#textをxmlファイルから削除する方法#
これは取り外し空白の後に私の元のxmlファイル
<book genre='novel' ISBN='1-861003-78' misc='sale-item'>
<title>The Handmaid's Tale</title>
<price>14.95</price>
</book>
これは私の新しいXMLファイルである
<!--sample XML fragment--><book genre='novel' ISBN='1-861003-78' misc='sale-item'><title>The Handmaid's Tale</title><price>14.95</price></book>
私は2つのXMLファイルを検証しようとしていますと、これはコード
static bool structValidate(XmlNodeList xmlOldNode, XmlNodeList xmlNewNode)
{
if (xmlOldNode.Count != xmlNewNode.Count) return true;
for (var i = 0; i < xmlOldNode.Count; i++)
{
var nodeA = xmlOldNode[i];
var nodeB = xmlNewNode[i];
Console.WriteLine("\n" + nodeA.Name + ":");
Console.WriteLine("\n" + nodeB.Name + ":");
Console.ReadLine();
if (nodeA.Attributes == null )
{
if (nodeB.Attributes != null)
return true;
else
continue;
}
if (nodeA.Attributes.Count != nodeB.Attributes.Count
|| nodeA.Name != nodeB.Name) return true;
for (var j = 0; j < nodeA.Attributes.Count; j++)
{
var attrA = nodeA.Attributes[j];
var attrB = nodeB.Attributes[j];
Console.WriteLine(attrA.Name);
Console.WriteLine(attrB.Name);
Console.ReadLine();
if (attrA.Name != attrB.Name) return true;
}
if (nodeA.HasChildNodes && nodeB.HasChildNodes)
{
return structValidate(nodeA.ChildNodes, nodeB.ChildNodes);
}
else
{
return false;
}
}
return false;
}
です
印刷中に#textを取得しています
あなたは、正確な要件は何ですか?空白なしでXMLを保存しますか?または他の操作をしたいですか? – Thakur
私の正確な操作は、2つのXMLファイルの構造を比較することです。たとえば
です。スキーマを使用してXMLスキーマを作成してXMLを検証しないのはなぜですか? – Thakur