Open xgqfrms opened 6 years ago
xml
file in js ?XML 标签必须严格的使用标签闭合。
<?xml version="1.0" encoding="utf-8" ?>
<BookList>
<Book>
<Title>jQuery: Novice to Ninja</Title>
<Publisher>Site point</Publisher>
</Book>
<Book>
<Title>Learning jQuery</Title>
<Publisher>PACKT</Publisher>
</Book>
<Book>
<Title>Head First jQuery</Title>
<Publisher>O'Reilly</Publisher>
</Book>
<Book>
<Title>jQuery UI 1.8</Title>
<Publisher>PACKT</Publisher>
</Book>
</BookList>
XMLSerializer()
https://stackoverflow.com/questions/349250/how-to-display-xml-in-javascript
const xml_serializer = new XMLSerializer();
http://www.jquerybyexample.net/2012/04/read-and-process-xml-using-jquery-ajax.html
http://www.peachpit.com/articles/article.aspx?p=29307&seqNum=4
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>pre & XML & format & heiglight</title>
<style>
[data-pre="xml"],
[data-div="xml"] {
border: 1px solid red;
width: 400px;
height: 300px;
}
title {
color: #000;
display: block;
}
</style>
</head>
<body>
<section>
<h1>pre & XML & format & heiglight</h1>
<pre data-pre="xml"></pre>
<div data-div="xml"></div>
<iframe src="./book.xml" frameborder="1"></iframe>
</section>
<script>
const xmlString = `
<?xml version="1.0" encoding="utf-8" ?>
<BookList>
<Book>
<Title>jQuery: Novice to Ninja</Title>
<Publisher>Site point</Publisher>
</Book>
<Book>
<Title>Learning jQuery</Title>
<Publisher>PACKT</Publisher>
</Book>
<Book>
<Title>Head First jQuery</Title>
<Publisher>O'Reilly</Publisher>
</Book>
<Book>
<Title>jQuery UI 1.8</Title>
<Publisher>PACKT</Publisher>
</Book>
</BookList>
`;
// const xmlString = `<?xml version="1.0" encoding="utf-8" ?> <BookList> <Book> <Title>jQuery: Novice to Ninja</Title> <Publisher>Site point</Publisher> </Book> <Book> <Title>Learning jQuery</Title> <Publisher>PACKT</Publisher> </Book> <Book> <Title>Head First jQuery</Title> <Publisher>O'Reilly</Publisher> </Book> <Book> <Title>jQuery UI 1.8</Title> <Publisher>PACKT</Publisher> </Book> </BookList>`;
let preBox = document.querySelector(`[data-pre="xml"]`);
let divBox = document.querySelector(`[data-div="xml"]`);
//
let newXxmlString = xmlString.replace(/</ig, "<").replace(/>/ig, "><br>");
preBox.insertAdjacentHTML(`beforeend`, newXxmlString);
divBox.insertAdjacentHTML(`beforeend`, newXxmlString);
// preBox.insertAdjacentHTML(`beforeend`, xmlString);
// divBox.insertAdjacentHTML(`beforeend`, xmlString);
</script>
</body>
</html>
<?xml version="1.0" encoding="utf-8" ?>
<BookList>
<Book>
<Title>jQuery: Novice to Ninja</Title>
<Publisher>Site point</Publisher>
</Book>
<Book>
<Title>Learning jQuery</Title>
<Publisher>PACKT</Publisher>
</Book>
<Book>
<Title>Head First jQuery</Title>
<Publisher>O'Reilly</Publisher>
</Book>
<Book>
<Title>jQuery UI 1.8</Title>
<Publisher>PACKT</Publisher>
</Book>
</BookList>
https://stackoverflow.com/questions/160694/syntax-highlighting-code-with-javascript
https://en.wikipedia.org/wiki/Syntax_highlighting
https://chrome.google.com/webstore/detail/codehighlight/gioojphhkmhanbjankdapnegcodlellc
https://github.com/google/code-prettify
chrome://extensions
chrome://extensions/?id=ghgabhipcejejjmhhchfonmamedcbeod
.crx
https://www.hotcleaner.com/clickclean_chrome.html
https://chrome.google.com/webstore/detail/ghgabhipcejejjmhhchfonmamedcbeod
https://www32.zippyshare.com/v/4YpRIFdi/file.html
localStorage