単純なxmlfileがあり、それはツリービューに配置されます
<bookstore xmlns="generic">
<book genre="Book" >`
<title>Book of Benjamin Franklin</title>
<author>
<first-name>Benson</first-name>
<last-name>Frank</last-name>
</author>
<price>89.88</price>
</book>
<book genre="autobiography">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Ben</first-name>
<middlename />
<last-name>Franklin</last-name>
</author>
<price>89.88</price>
</book>
<book genre="novel" >
<title>The Confidence Man</title>
<author>
<first-name>John</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
</book>
</bookstore>
交換したい(2要素目)
<book genre="autobiography" >
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Ben</first-name>
<middlename />
<last-name>Franklin</last-name>
</author>
<price>89.88</price>
</book>
別の要素で(編集され、部分を文字列として編集しました)
<book genre="autobiography">
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Ben</first-name>
<last-name>Franklin</last-name>
</author>
<price>89.88</price>
</book>
私が使用したコードはここにあります
XElement XmlTree = XElement.Parse(text);//text contain edited portion
XmlElement XMLE = (XmlElement)TreeV.SelectedItem;
XmlDocument xdoc = new XmlDocument();
xdoc.Load(scd_file);
XmlDocumentFragment xfrag = xdoc.CreateDocumentFragment();
xfrag.InnerXml = text;
XmlDocumentFragment xfrag1 = xdoc.CreateDocumentFragment();
xfrag1.InnerXml = XMLE.OuterXml;
xdoc.ReplaceChild(xfrag, xfrag1);
しかし、エラーが表示されます(xfrag1はxdocのノードではありません)。この問題を解決するのを手伝ってください。