【发布时间】:2021-02-11 10:56:12
【问题描述】:
我正在使用一个内部有 XML 和 Java Script 插件的应用程序。我需要获取指定属性的值。我正在尝试使用以下命令获取 TEST 元素的 id 值,但出现了错误的值。
System.log(document.getDocumentElement("TEST").getAttributes().getNamedItem('id').value);
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Task id="123456">
<TEST href="https://portal/api/product/5fb26d98-3590-4b7a-9af6-264468b33a83" id="5fb26d98-3590-4b7a-9af6-264468b33a83" name="TEST" type="application/xml"/>
<TEST2 href="https://portal/api/product/1fb26d98-3590-4b7a-9af6-264468b33a80" id="1fb26d98-3590-4b7a-9af6-264468b33a80" name="TEST2" type="application/xml"/>
</Task>
当我尝试使用此命令时,“123456”值即将到来。怎么了?
【问题讨论】:
标签: javascript xml dom