// Reads the first and last name of each person and adds a new attribute with// the full name.letxml='<roster>'+'<person first="John" last="Doe"/>'+'<person first="Mary" last="Smith"/>'+'</roster>';constdocument=XmlService.parse(xml);constpeople=document.getRootElement().getChildren('person');for(leti=0;i < people.length;i++){constperson=people[i];constfirstName=person.getAttribute('first').getValue();constlastName=person.getAttribute('last').getValue();person.setAttribute('full',`${firstName}${lastName}`);}xml=XmlService.getPrettyFormat().format(document);Logger.log(xml);
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-12-22 UTC。"],[[["`Attribute` object represents an XML attribute and provides methods for manipulating its name, namespace, and value."],["You can get an attribute's local name using `getName()`, its namespace using `getNamespace()`, and its value using `getValue()`."],["`setName()`, `setNamespace()`, and `setValue()` allow modifying an attribute's local name, namespace, and value respectively."],["The provided code example demonstrates how to iterate through XML elements, access their attributes, and add new attributes."]]],["The `Attribute` class represents an XML attribute, allowing for manipulation of its properties. Key actions include retrieving the attribute's name, namespace, and value using `getName()`, `getNamespace()`, and `getValue()`. Modifications are possible via `setName(name)`, `setNamespace(namespace)`, and `setValue(value)`. An example demonstrates reading \"first\" and \"last\" names from an XML, creating a new \"full\" attribute by concatenating these names. The methods allow retrieving and setting of attribute data.\n"]]