-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0335046
commit 0984fad
Showing
12 changed files
with
214 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head></head> | ||
<body> | ||
<h1>XML Parser Example</h1> | ||
<div id="output"></div> | ||
|
||
<script> | ||
// Sample XML data as a string | ||
const xmlString = ` | ||
<bookstore> | ||
<book category="children"> | ||
<title lang="en">Harry Potter</title> | ||
<author>J K. Rowling</author> | ||
<year>2005</year> | ||
<price>29.99</price> | ||
</book> | ||
<book category="web"> | ||
<title lang="en">Learning XML</title> | ||
<author>Erik T. Ray</author> | ||
<year>2003</year> | ||
<price>39.95</price> | ||
</book> | ||
</bookstore> | ||
`; | ||
|
||
// Parse the XML string into a DOM object | ||
const parser = new DOMParser(); | ||
const xmlDoc = parser.parseFromString(xmlString, "application/xml"); | ||
|
||
// Find all book elements | ||
const books = xmlDoc.getElementsByTagName('book'); | ||
|
||
// Output div | ||
const outputDiv = document.getElementById('output'); | ||
|
||
// Iterate over each book and display its data | ||
for (let i = 0; i < books.length; i++) { | ||
const category = books[i].getAttribute('category'); | ||
const title = books[i].getElementsByTagName('title')[0].textContent; | ||
const author = books[i].getElementsByTagName('author')[0].textContent; | ||
const year = books[i].getElementsByTagName('year')[0].textContent; | ||
const price = books[i].getElementsByTagName('price')[0].textContent; | ||
|
||
outputDiv.innerHTML += ` | ||
<div> | ||
<strong>Category:</strong> ${category}<br> | ||
<strong>Title:</strong> ${title}<br> | ||
<strong>Author:</strong> ${author}<br> | ||
<strong>Year:</strong> ${year}<br> | ||
<strong>Price:</strong> ${price}<br> | ||
<hr> | ||
</div> | ||
`; | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head></head> | ||
<body> | ||
<h1>XML Parser Example</h1> | ||
<div id="output"></div> | ||
|
||
<script> | ||
// Sample XML data as a string | ||
const xmlString = ` | ||
<bookstore> | ||
<book category="children"> | ||
<title lang="en">Harry Potter</title> | ||
<author>J K. Rowling</author> | ||
<year>2005</year> | ||
<price>29.99</price> | ||
</book> | ||
<book category="web"> | ||
<title lang="en">Learning XML</title> | ||
<author>Erik T. Ray</author> | ||
<year>2003</year> | ||
<price>39.95</price> | ||
</book> | ||
</bookstore> | ||
`; | ||
|
||
// Parse the XML string into a DOM object | ||
const parser = new DOMParser(); | ||
const xmlDoc = parser.parseFromString(xmlString, "application/xml"); | ||
|
||
// Find all book elements | ||
const books = xmlDoc.getElementsByTagName('book'); | ||
|
||
// Output div | ||
const outputDiv = document.getElementById('output'); | ||
|
||
// Iterate over each book and display its data | ||
for (let i = 0; i < books.length; i++) { | ||
const category = books[i].getAttribute('category'); | ||
const title = books[i].getElementsByTagName('title')[0].textContent; | ||
const author = books[i].getElementsByTagName('author')[0].textContent; | ||
const year = books[i].getElementsByTagName('year')[0].textContent; | ||
const price = books[i].getElementsByTagName('price')[0].textContent; | ||
|
||
outputDiv.innerHTML += ` | ||
<div> | ||
<strong>Category:</strong> ${category}<br> | ||
<strong>Title:</strong> ${title}<br> | ||
<strong>Author:</strong> ${author}<br> | ||
<strong>Year:</strong> ${year}<br> | ||
<strong>Price:</strong> ${price}<br> | ||
<hr> | ||
</div> | ||
`; | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Create a XSLT document for and taken xml document by you with all steps--> | ||
<!-- Create a XSLT document for and taken xml document by you with all steps--> | ||
<?xml-stylesheet type="text/xsl" href="Program29.xsl"?> | ||
<catalog> | ||
<cd> | ||
<title>Empire Burlesque</title> | ||
<artist>Bob Dylan</artist> | ||
<country>USA</country> | ||
<company>Columbia</company> | ||
<price>10.90</price> | ||
<year>1985</year> | ||
</cd> | ||
</catalog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<xsl:template match="/"> | ||
<html> | ||
<body> | ||
<h2>My CD Collection</h2> | ||
<table border="1"> | ||
<tr bgcolor="#9acd32"> | ||
<th>Title</th> | ||
<th>Artist</th> | ||
</tr> | ||
<xsl:for-each select="catalog/cd"> | ||
<tr> | ||
<td><xsl:value-of select="title"/></td> | ||
<td><xsl:value-of select="artist"/></td> | ||
</tr> | ||
</xsl:for-each> | ||
</table> | ||
</body> | ||
</html> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head></head> | ||
<body> | ||
<h1>XML Parser Example</h1> | ||
<div id="output"></div> | ||
|
||
<script> | ||
// Sample XML data as a string | ||
const xmlString = ` | ||
<bookstore> | ||
<book category="children"> | ||
<title lang="en">Harry Potter</title> | ||
<author>J K. Rowling</author> | ||
<year>2005</year> | ||
<price>29.99</price> | ||
</book> | ||
<book category="web"> | ||
<title lang="en">Learning XML</title> | ||
<author>Erik T. Ray</author> | ||
<year>2003</year> | ||
<price>39.95</price> | ||
</book> | ||
</bookstore> | ||
`; | ||
|
||
// Parse the XML string into a DOM object | ||
const parser = new DOMParser(); | ||
const xmlDoc = parser.parseFromString(xmlString, "application/xml"); | ||
|
||
// Find all book elements | ||
const books = xmlDoc.getElementsByTagName('book'); | ||
|
||
// Output div | ||
const outputDiv = document.getElementById('output'); | ||
|
||
// Iterate over each book and display its data | ||
for (let i = 0; i < books.length; i++) { | ||
const category = books[i].getAttribute('category'); | ||
const title = books[i].getElementsByTagName('title')[0].textContent; | ||
const author = books[i].getElementsByTagName('author')[0].textContent; | ||
const year = books[i].getElementsByTagName('year')[0].textContent; | ||
const price = books[i].getElementsByTagName('price')[0].textContent; | ||
|
||
outputDiv.innerHTML += ` | ||
<div> | ||
<strong>Category:</strong> ${category}<br> | ||
<strong>Title:</strong> ${title}<br> | ||
<strong>Author:</strong> ${author}<br> | ||
<strong>Year:</strong> ${year}<br> | ||
<strong>Price:</strong> ${price}<br> | ||
<hr> | ||
</div> | ||
`; | ||
} | ||
</script> | ||
</body> | ||
</html> |
Binary file not shown.
Binary file not shown.
Binary file not shown.