经典 ASP XMLDom 读取根节点名称

Classic ASP XMLDom read Root Node Name

我收到这条 xml 短信

<InsertProductsRequest>
    <ProductsContainer>
        <Product>
            <ProductCode>AB25E</ProductCode>
            <Description>Good Item bla bla...</Description>
            <Price>25.5</Price>
            <Currency>EUR</Currency>
            ......
            <ShippingService>DHL</ShippingService>
            <ShippingService>TNT</ShippingService>
        </Product>
    </ProductsContainer>
</InsertProductsRequest>

使用经典 ASP 和 Microsoft.XMLDOM

如何获取根节点名称,因此"InsertProductsRequest"

谢谢 乔

您需要使用tagName property of the documentElement

'the string containing xml document
xml = "<InsertProductsRequest></InsertProductsRequest>"

Set doc = Server.CreateObject("MSXML2.DomDocument")
doc.loadXML xml

Response.Write doc.documentElement.tagName