// 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"]]