XML 속성을 나타냅니다.
// Reads the first and last name of each person and adds a new attribute with // the full name. let xml = '<roster>' + '<person first="John" last="Doe"/>' + '<person first="Mary" last="Smith"/>' + '</roster>'; const document = XmlService.parse(xml); const people = document.getRootElement().getChildren('person'); for (let i = 0; i < people.length; i++) { const person = people[i]; const firstName = person.getAttribute('first').getValue(); const lastName = person.getAttribute('last').getValue(); person.setAttribute('full', `${firstName} ${lastName}`); } xml = XmlService.getPrettyFormat().format(document); Logger.log(xml);
메서드
| 메서드 | 반환 유형 | 간략한 설명 |
|---|---|---|
get | String | 속성의 로컬 이름을 가져옵니다. |
get | Namespace|null | 속성의 네임스페이스를 가져옵니다. |
get | String | 속성의 값을 가져옵니다. |
set | Attribute | 속성의 로컬 이름을 설정합니다. |
set | Attribute | 속성의 네임스페이스를 설정합니다. |
set | Attribute | 속성의 값을 설정합니다. |
자세한 문서
getName()
속성의 로컬 이름을 가져옵니다. 속성에 네임스페이스 프리픽스가 있는 경우 getNamespace()를 사용합니다.getPrefix()를 사용하여 프리픽스를 가져옵니다.
리턴
String — 속성의 로컬 이름입니다.
getNamespace()
getValue()
속성의 값을 가져옵니다.
리턴
String — 속성의 값입니다.
setName(name)
속성의 로컬 이름을 설정합니다. 속성의 네임스페이스 프리픽스를 설정하려면 XmlService.getNamespace(prefix, uri)와 함께 setNamespace(namespace)를 사용합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
name | String | 설정할 로컬 이름입니다. |
리턴
Attribute — 연결을 위한 속성입니다.