1
<%
    Set xmlDoc = Server.CreateObject("MSXML2.DOMDOCUMENT")
    xmlDoc.loadXML( "<response />" )

    Set node = xmlDoc.createElement("account")
    xmlDoc.documentElement.AppendChild node

    Set node = xmlDoc.createElement("type")
    node.Text = "TheType"
    xmlDoc.documentElement.AppendChild node

    Set node = Nothing
%>

これにより、次のような XML ドキュメントが作成されます。

   <response>
        <account></account>
        <type>TheType</type>
   </response>

「type」ノードを子ノードとして「newaccount」ノードに追加して、次のようにするにはどうすればよいですか。

   <response>
        <account>
            <type>TheType</type>
        </account>
   </response>
4

1 に答える 1

4

ドキュメント要素に追加するのと同じ方法:

Set accountEl = xmlDoc.createElement("account")
xmlDoc.documentElement.AppendChild accountEl

Set typeEl = xmlDoc.createElement("type")
typeEl.Text = "TheType"
accountEl.AppendChild typeEl

accountEl = Nothing
typeEl = Nothing
于 2008-11-12T15:36:59.127 に答える