如何获得儿童节点"描述"one_answers"创建-at"的值/文本?一年前,我已经有这个工作,但是现在我无法再次工作。请帮助。
xmlPath := "C:Scriptdoc.xml"
xmlDoc := ComObjCreate("MSXML2.DOMDocument.6.0")
xmlDoc.async := false
xmlDoc.load(xmlPath)
for item in xmlDoc.getElementsByTagName("ticket") {
string := item.text
stringDesc := item.getAttribute("description").text
stringTime := item.getAttribute("created-at").text
FileAppend, %string%, C:Scripthtmlversion.html
FileAppend, %stringDesc%, C:Scripthtmlversion.html
FileAppend, %stringTime%, C:Scripthtmlversion.html
}
XML:
<ticket>
<id type="integer">31</id>
<description> This is some text I want to access. </description>
<created-at type="dateTime">2018-02-14T11:27:52+01:00</created-at>
</ticket>
第一个作品:
string := item.text
但不是其他两个:
stringDesc := item.getAttribute("description").text
stringTime := item.getAttribute("created-at").text
description
和 created-at
在您的示例情况下不是属性。
您应该尝试:
for item in xmlDoc.getElementsByTagName("ticket") {
string := item.text
}
for item in xmlDoc.getElementsByTagName("description") {
stringDesc := item.text
}
for item in xmlDoc.getElementsByTagName("created-at") {
stringTime := item.text
}