我第一次嘗試生成這種型別的檔案,不是很熟悉,請幫幫我。我想達到以下效果
<ExtendedData xmlns:mis="www.dji.com">
<mis:actions param="240" label="zoom" >CameraZoom</mis:actions>
</ExtendedData>
我的代碼是
writer.WriteStartElement("mis", "ExtendedData", "www.dji.com");
writer.WriteStartElement("mis", "actions", "www.dji.com");
writer.WriteAttributeString("param", "240");
writer.WriteAttributeString("label", "zoom");
writer.WriteString("CameraZoom");
writer.WriteEndElement();
它是這樣作業的:
<mis:ExtendedData xmlns:mis="www.dji.com">
<mis:actions param="240" label="zoom" >CameraZoom</mis:actions>
</mis:ExtendedData>
我需要做什么才能從“<mis:ExtendedData xmlns:mis="www.dji.com">”中洗掉“mis:”前綴
uj5u.com熱心網友回復:
Microsoft 檔案(我假設這是 .NET XmlWriter?)給出了示例
// Write an element (this one is the root).
writer.WriteStartElement("book");
// Write the namespace declaration.
writer.WriteAttributeString("xmlns", "bk", null, "urn:samples");
用于撰寫一個沒有在元素名稱中實際使用的命名空間宣告的無命名空間元素。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/411830.html
標籤:
