ייצוג של מאפיין 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);
Methods
| שיטה | סוג הערך המוחזר | תיאור קצר |
|---|---|---|
get | String | הפונקציה מקבלת את השם המקומי של המאפיין. |
get | Namespace | הפונקציה מקבלת את מרחב השמות של המאפיין. |
get | String | הפונקציה מקבלת את הערך של המאפיין. |
set | Attribute | הגדרת השם המקומי של המאפיין. |
set | Attribute | הגדרת מרחב השמות של המאפיין. |
set | Attribute | הגדרת הערך של המאפיין. |
מסמכים מפורטים
get Name()
הפונקציה מקבלת את השם המקומי של המאפיין. אם למאפיין יש קידומת של מרחב שמות, צריך להשתמש ב-get.get כדי לקבל את הקידומת.
חזרה
String – השם המקומי של המאפיין
get Namespace()
get Value()
הפונקציה מקבלת את הערך של המאפיין.
חזרה
String – הערך של המאפיין
set Name(name)
הגדרת השם המקומי של המאפיין. כדי להגדיר תחילית של מרחב שמות למאפיין, משתמשים ב-set בשילוב עם Xml.
פרמטרים
| שם | סוג | תיאור |
|---|---|---|
name | String | השם המקומי שרוצים להגדיר |
חזרה
Attribute – המאפיין, לשרשור