From the course: Google Apps Script for JavaScript Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Traversing a Google Doc

Traversing a Google Doc - Google Docs Tutorial

From the course: Google Apps Script for JavaScript Developers

Start my 1-month free trial

Traversing a Google Doc

- [Instructor] Now that we've begun cleaning up our new script that converts our Google doc into markdown let's take a look at how we can traverse the elements of the Google doc itself. To begin, let's remove the activeSection.getText call To begin, let's remove the activeSection.getText call and we're going to make text equal to an empty string. Next we're going to want to get the number of children inside of the active section. We'll create a new variable and call this total. We'll set this equal to active section and call .getNumChildren. and call .getNumChildren. Each element inside of a document is a child of a parent element. The structure of Google documents are very similar to what you'd come to expect in something like an XML document or an HTML file. like an XML document or an HTML file. There are sets of APIs that allow us to easily go through each of the elements, pull them out, understand what they are, and deal with them based on their types by getting the number of…

Contents