From the course: XML Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Creating document content - XML Tutorial
From the course: XML Essential Training
Creating document content
- [Instructor] In the previous example, we saw how to use the DOM API to discover and extract document content. In this example, we're going to see how to use the DOM to create new document content. So let's open up DOMexample3_start. So this script code should be a little familiar by now. We're getting the element ID for the xml data which, again, is down here in the document. You can see right here. And you get elements by tag name function is getting the businessCard. So, again, nothing new here so far. So, we are going to fill out this function called createBizCards. And this function gets called when the document loads. Now one thing I want you to notice is that in the xml section, I made a slight adjustment. I have a new root tag named BusinessCards. And the reason for that is because I want to have more than one business card in the file. So our code will start off with a loop that iterates over all the elements of the bizCards array. So let me do this, say. So then I'll have a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.