एक्सएमएल एट्रिब्यूट का उदाहरण.
// 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 | एट्रिब्यूट का नेमस्पेस पाता है. |
get | String | एट्रिब्यूट की वैल्यू पाता है. |
set | Attribute | एट्रिब्यूट का स्थानीय नाम सेट करता है. |
set | Attribute | एट्रिब्यूट के लिए नेमस्पेस सेट करता है. |
set | Attribute | एट्रिब्यूट की वैल्यू सेट करता है. |
ज़्यादा जानकारी वाला दस्तावेज़
get Name()
एट्रिब्यूट का स्थानीय नाम दिखाता है. अगर एट्रिब्यूट में नेमस्पेस प्रीफ़िक्स है, तो get का इस्तेमाल करें.get पर क्लिक करें.
वापसी का टिकट
String — एट्रिब्यूट का स्थानीय नाम
get Namespace()
get Value()
एट्रिब्यूट की वैल्यू पाता है.
वापसी का टिकट
String — एट्रिब्यूट की वैल्यू
set Name(name)
एट्रिब्यूट का स्थानीय नाम सेट करता है. एट्रिब्यूट के लिए नेमस्पेस प्रीफ़िक्स सेट करने के लिए, Xml के साथ set का इस्तेमाल करें.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
name | String | सेट किया जाने वाला स्थानीय नाम |
वापसी का टिकट
Attribute — चेन करने के लिए एट्रिब्यूट
set Namespace(namespace)
set Value(value)
एट्रिब्यूट की वैल्यू सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
value | String | सेट की जाने वाली वैल्यू |
वापसी का टिकट
Attribute — चेन करने के लिए एट्रिब्यूट