У меня проблемы с получением выходного XML-файла в ожидаемый файл.
Я хочу это:
<Book id="RED" desc="All about the color." mmtype="NO">
</Book>
Но то, что я получаю, это:
<Book id="RED" desc="All about the color." mmtype="NO" />
Мой код для создания узла:
XmlNode newNode = _xmlDocument.CreateElement("Book");
//Add Attributes
XmlAttribute attrID = _xmlDocument.CreateAttribute("id");
attrID.Value = newBook.ID;
newNode.Attributes.Append(attrID);
XmlAttribute attrDesc = this._xmlDocument.CreateAttribute("desc");
attrDesc.Value = newBook.Description;
newNode.Attributes.Append(attrDesc);
XmlAttribute attrMmType = this._xmlDocument.CreateAttribute("mmtype");
attrMmType.Value = newBook.mmType;
newNode.Attributes.Append(attrMmType);
//Add new child node to parent
parentNode.InsertBefore(newNode, parentNode.FirstChild);
Я не вижу, как настроить узел по-другому, чтобы получить результат блока.
Возможно, мне нужно добавить дочерний узел перед его сохранением? Но у меня нет никаких
для этого конкретного узла.
Любая помощь будет оценена.