0
我正在將代碼從vbs更改爲C#,但是我有一個XMLwriter問題,如何使用XML編寫在XML.file中獲取此類輸出:??如何使用XmlWriter在元素中編寫名稱空間
我有這樣的代碼:
using (XmlWriter writer = XmlWriter.Create(Form1.systemDrive + "\\unattend.xml"))
{
writer.WriteStartDocument();
writer.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
writer.WriteStartElement("unattend");
writer.WriteAttributeString("xmlns", "urn:schemas-microsoft-com:unattend"); // <<<<<<< Gives an error
....
你能提供預期的產出嗎?你會得到什麼錯誤? – tdragon
您需要[使用WriteAttributeString的不同重載](https://msdn.microsoft.com/en-us/library/73z46xs1(v = vs.110).aspx)編寫名稱空間聲明。 – stuartd
「一個錯誤」總是對你得到的錯誤的一個很好的描述......: - /就像「不工作」一樣。 –