이 서비스를 사용하면 스크립트가 XML 문서를 파싱, 탐색, 프로그래매틱 방식으로 만들 수 있습니다.
// Log the title and labels for the first page of blog posts on// Google's The Keyword blog.functionparseXml(){leturl='https://blog.google/rss/';letxml=UrlFetchApp.fetch(url).getContentText();letdocument=XmlService.parse(xml);letroot=document.getRootElement();letchannel=root.getChild('channel');letitems=channel.getChildren('item');items.forEach(item=>{lettitle=item.getChild('title').getText();letcategories=item.getChildren('category');letlabels=categories.map(category=>category.getText());console.log('%s (%s)',title,labels.join(', '));});}// Create and log an XML representation of first 10 threads in your Gmail inbox.functioncreateXml(){letroot=XmlService.createElement('threads');letthreads=GmailApp.getInboxThreads()threads=threads.slice(0,10);// Just the first 10threads.forEach(thread=>{letchild=XmlService.createElement('thread').setAttribute('messageCount',thread.getMessageCount()).setAttribute('isUnread',thread.isUnread()).setText(thread.getFirstMessageSubject());root.addContent(child);});letdocument=XmlService.createDocument(root);letxml=XmlService.getPrettyFormat().format(document);console.log(xml);}
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2024-12-21(UTC)"],[[["Google Apps Script's XML Service allows you to programmatically interact with XML data, including parsing existing XML and creating new XML documents."],["The service provides a comprehensive set of classes and methods for manipulating XML elements, attributes, and the overall document structure."],["`XmlService.parse` is used to parse XML data from a given string or URL, while methods like `createElement` and `setAttribute` enable building new XML structures."],["You can extract specific data from XML documents by navigating their structure using methods like `getChild`, `getChildren`, and `getAttribute`."],["The `XmlService` facilitates various use cases, such as data extraction, document generation, and integration with XML-based APIs within your Google Apps Script projects."]]],[]]