Class Attribute

속성

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);

메서드

메서드반환 유형간략한 설명
getName()String속성의 로컬 이름을 가져옵니다.
getNamespace()Namespace|null속성의 네임스페이스를 가져옵니다.
getValue()String속성의 값을 가져옵니다.
setName(name)Attribute속성의 로컬 이름을 설정합니다.
setNamespace(namespace)Attribute속성의 네임스페이스를 설정합니다.
setValue(value)Attribute속성의 값을 설정합니다.

자세한 문서

getName()

속성의 로컬 이름을 가져옵니다. 속성에 네임스페이스 프리픽스가 있는 경우 getNamespace()를 사용합니다.getPrefix()를 사용하여 프리픽스를 가져옵니다.

리턴

String — 속성의 로컬 이름입니다.


getNamespace()

속성의 네임스페이스를 가져옵니다.

리턴

Namespace|null — 속성의 네임스페이스입니다.


getValue()

속성의 값을 가져옵니다.

리턴

String — 속성의 값입니다.


setName(name)

속성의 로컬 이름을 설정합니다. 속성의 네임스페이스 프리픽스를 설정하려면 XmlService.getNamespace(prefix, uri)와 함께 setNamespace(namespace)를 사용합니다.

매개변수

이름유형설명
nameString설정할 로컬 이름입니다.

리턴

Attribute — 연결을 위한 속성입니다.


setNamespace(namespace)

속성의 네임스페이스를 설정합니다. 네임스페이스에는 프리픽스가 있어야 합니다.

매개변수

이름유형설명
namespaceNamespace설정할 네임스페이스입니다.

리턴

Attribute — 연결을 위한 속성입니다.


setValue(value)

속성의 값을 설정합니다.

매개변수

이름유형설명
valueString설정할 값입니다.

리턴

Attribute — 연결을 위한 속성입니다.