gpt4 book ai didi

asp-classic - ASP 经典 - 解析 XML InnerXML

转载 作者:行者123 更新时间:2023-12-01 12:54:56 25 4
gpt4 key购买 nike

我希望能够像 asp.net 一样解析值,不幸的是 asp classic 也返回像 <div>everything within it</div> 这样的标签。标签。

我正在尝试解析路径“/root/div”并返回其中的所有内容,不包括“<div></div>”,结果应该是“<p>abc <span>other span</span></p>

<%
Set CurrentXML=Server.CreateObject("Microsoft.XMLDOM")
CurrentXML.LoadXml("<root><div><p>abc <span>other span</span></p></div></root>")'Load string into CurrentXML

Response.Write("<BR>"&Server.HTMLEncode(CurrentXML.SelectSingleNode("/root/div").XML)) 'I want to return without the div, the correct result should be <p>abc <span>other span</span></p>
%>

最佳答案

试试这个:

<%
Option Explicit

Dim xml: Set xml = Server.CreateObject("MSXML2.DOMDocument.3.0")
xml.LoadXml("<root><div>Text Start<p>abc <span>other span</span></p></div></root>")

Dim sResult: sResult = ""

Dim node
For Each node in xml.selectSingleNode("/root/div").childNodes
sResult = sResult & node.xml
Next

Response.Write Server.HTMLEncode(sResult)

%>

不幸的是,MSXML DOM 元素没有 innerXml 属性。因此,您需要循环以连接每个子节点的 xml 以生成元素的内部 XML。

关于asp-classic - ASP 经典 - 解析 XML InnerXML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10375403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com