似乎有一些有趣的行爲去,當我打電話的XmlTextWriter上...當我使用XmlTextWriter類時,爲什麼chevron編碼不同?
XmlTextWriter writer = new XmlTextWriter(targetFileName, Encoding.UTF8);
writer.WriteValue("< ?xml version=\"1.0\" encoding=\"UTF-8\"?>");
writer.WriteString(Environment.NewLine);
writer.WriteStartElement("video","UploadXsd");
writer.WriteString(Environment.NewLine);
writer.WriteStartElement("title");
writer.WriteString(Environment.NewLine);
writer.WriteString(title);
writer.WriteString(Environment.NewLine);
writer.WriteEndElement();
writer.WriteString(Environment.NewLine);
writer.WriteStartElement("description");
writer.WriteString(Environment.NewLine);
writer.WriteString(description);
writer.WriteString(Environment.NewLine);
writer.WriteEndElement();
writer.WriteString(Environment.NewLine);
writer.WriteStartElement("contributor");
writer.WriteString(Environment.NewLine);
writer.WriteString(contributor);
writer.WriteString(Environment.NewLine);
writer.WriteEndElement();
writer.WriteString(Environment.NewLine);
writer.WriteStartElement("subject");
writer.WriteString(Environment.NewLine);
writer.WriteString(subject);
writer.WriteString(Environment.NewLine);
writer.WriteEndElement();
writer.WriteString(Environment.NewLine);
writer.WriteEndElement();
writer.WriteString(Environment.NewLine);
writer.Flush();
writer.Close();
然後我看到它正在創造這樣的:
< ?xml version="1.0" encoding="UTF-8"?>
<video xmlns="UploadXsd">
<title>
MyTitle
</title>
<description>
MyDescription
</description>
<contributor>
MyContributor
</contributor>
<subject>
MySubject
</subject>
</video>
爲什麼筆者編碼的第一要素進入Html,但不是其餘?,更重要的是,如何阻止它這樣做?我只想創建第一個元素。
這是偉大的感謝將在一分鐘內接受 – Exitos