【发布时间】:2020-11-26 20:52:47
【问题描述】:
XML 代码
<directory>
<fieldset>
<field id="displayName">Display name</field>
</fieldset>
<employees>
<employee id="123">
<field id="displayName">John Doe</field>
</employee>
<employee id="160">
<field id="displayName">Jane Doe</field>
</employee>
我可以使用 XmlService.parse 解析信息并获取每个元素中的值,但我无法获取员工/元素 ID 号
当我运行这个时:
var roots = document.getRootElement().getChild('employees').getChildren();
我得到了单个元素,但我无法得到 id 的
[[Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>], [Element: <employee/>]]
【问题讨论】:
标签: javascript arrays xml google-apps-script