Una rappresentazione di un attributo 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);
Metodi
| Metodo | Tipo restituito | Breve descrizione | 
|---|---|---|
| get | String | Recupera il nome locale dell'attributo. | 
| get | Namespace | Recupera lo spazio dei nomi per l'attributo. | 
| get | String | Recupera il valore dell'attributo. | 
| set | Attribute | Imposta il nome locale dell'attributo. | 
| set | Attribute | Imposta lo spazio dei nomi per l'attributo. | 
| set | Attribute | Imposta il valore dell'attributo. | 
Documentazione dettagliata
get
Recupera il nome locale dell'attributo. Se l'attributo ha un prefisso dello spazio dei nomi, utilizza get.get per ottenere il prefisso.
Invio
String: il nome locale dell'attributo
get
get
Recupera il valore dell'attributo.
Invio
String: il valore dell'attributo
set
Imposta il nome locale dell'attributo. Per impostare un prefisso dello spazio dei nomi per l'attributo, utilizza set in combinazione con Xml.
Parametri
| Nome | Tipo | Descrizione | 
|---|---|---|
| name | String | Il nome locale da impostare | 
Invio
Attribute: l'attributo da concatenare
set
set
Imposta il valore dell'attributo.
Parametri
| Nome | Tipo | Descrizione | 
|---|---|---|
| value | String | il valore da impostare | 
Invio
Attribute: l'attributo da concatenare