Modern Rolls of JavaScript
Today, we will learn about the Document Object model built into every webpage, specifically the ability to target and store data as plain text using XML. You can read about the different XML DOM references here.
XML in conjunction with Javascript offers a unique ability to parse data. Where am I going with this?
If we can single out the XML note we created earlier in this challenge using JavaScript, then we can start handling data permanently. For those of us not aware of the potential JavaScript has to offer the web development industry, it's almost endless.

JavaScript is incredibly versatile and plays a crucial role in modern web development. Here are some of its most common and powerful uses:
- Client-Side Scripting
- Dynamic Content Update: Change the content of a web page without reloading it, like updating user profiles or fetching new posts.
- Form Validation: Validate user inputs in forms before submitting them to the server to reduce errors.
- Animations: Create smooth animations and transitions to enhance user experience.
- Server-Side Scripting
- Node.js: Run JavaScript on the server to build scalable and high-performance applications.
- API Endpoints: Handle HTTP requests and responses to create APIs for web applications.
- Interactive User Interfaces
- React.js: Build complex user interfaces with reusable components.
- Vue.js: Create engaging and interactive single-page applications.
- Real-Time Applications
- WebSockets: Enable real-time communication between client and server, useful for chat applications and live notifications.
- Socket.io: A library for enabling real-time, bi-directional communication between web clients and servers.
- Game Development
- Canvas API: Create 2D games and graphics-intensive applications.
- Three.js: Develop 3D graphics and games using WebGL.
- Mobile Applications
- React Native: Build cross-platform mobile apps using JavaScript and React.
- Cordova/Ionic: Create hybrid mobile applications using web technologies.
- Web APIs
- Fetch API/AJAX: Make asynchronous requests to retrieve data from a server without refreshing the page.
- Geolocation API: Get the geographical location of a user.
- Local Storage API: Store data on the client side for offline access or state persistence.
- Frameworks and Libraries
- jQuery: Simplify HTML document traversal, event handling, and animation.
- Angular: Build dynamic, single-page applications with a robust framework.
- Building and Automation Tools
- Webpack: Bundle JavaScript files for usage in the browser.
- Gulp: Automate and enhance your workflow with tasks like minification, compilation, and linting.
- Progressive Web Apps (PWAs)
- Service Workers: Create offline-first web applications and improve loading times.
- Manifest Files: Allow users to add web apps to their home screen and make them feel like native apps.
- Data Visualization
- D3.js: Create complex and beautiful data visualizations.
- Chart.js: Generate simple and interactive charts.
- Cross-Browser Compatibility
- Polyfills: Ensure that modern web applications work on older browsers by providing fallback functionality.
- Testing and Debugging
- Jest: A testing framework to ensure your code behaves as expected.
- Mocha/Chai: Libraries for writing and running tests, and for making assertions.
These are just some of the many ways JavaScript is used in web development. Its ecosystem is constantly evolving, providing new tools and libraries to enhance the development process.
Is there a specific area you’re interested in exploring further?
Content provided by Microsoft Copilot
JavaScript and XML Parsing Data
With this language targeting our XML, we will focus on parsing our data. the first thing you need is the XML data:
const xmlData = ` <dealership> <car id="1" type="truck"> <make>Toyota</make> <model>Tacoma</model> <year>1987</year> <owner> <name>Chris</name> <address> <street>12 ST</street> <city>Somewhere</city> <state>MT</state> <zip>12322</zip> </address> </owner> </car> </dealership>`;
Next, we will transform this XML string into an XML object using a couple of lines with Javascript:
parser = new DOMParser();
Next, we need to parse the XML in JavaScript:
const xmlDoc = parser.parseFromString(xmlData, "application/xml");
const car = xmlDoc.getElementsByTagName("car")[0];
const make = car.getElementsByTagName("make")[0].childNodes[0].nodeValue; const model = car.getElementsByTagName("model")[0].childNodes[0].nodeValue; const year = car.getElementsByTagName("year")[0].childNodes[0].nodeValue; const ownerName = car.getElementsByTagName("name")[0].childNodes[0].nodeValue; const ownerAddress = car.getElementsByTagName("address")[0]; const street = ownerAddress.getElementsByTagName("street")[0].childNodes[0].nodeValue; const city = ownerAddress.getElementsByTagName("city")[0].childNodes[0].nodeValue; const state = ownerAddress.getElementsByTagName("state")[0].childNodes[0].nodeValue; const zip = ownerAddress.getElementsByTagName("zip")[0].childNodes[0].nodeValue;
document.getElementById("demo").innerHTML = ` Make: ${make}<br> Model: ${model}<br> Year: ${year}<br> Owner: ${ownerName}<br> Address: ${street}, ${city}, ${state}, ${zip}`;