
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
pure-xml-view
Advanced tools
A simple lightweight web component for rendering XML data in a tree view format.
Majority of code DONE BY VIDE CODING, USE WITH CAUTION
Built this simply because I cannot find a simple XML view with expand/collapse functionality that I can use in vanilla JS.
npm install pure-xml-view
Then import it in your JS/TS file:
import 'pure-xml-view';
<script type="module" src="https://unpkg.com/pure-xml-view@1.0.0/dist/index.js"></script>
Download the pure-xml-view.js file and include it in your HTML:
<script type="module" src="path/to/pure-xml-view.js"></script>
After including the component, you can use it in your HTML:
<!-- Basic usage with XML as an attribute -->
<pure-xml-view data="<root><item>Content</item></root>"></pure-xml-view>
<!-- Or set the XML programmatically -->
<pure-xml-view id="my-viewer"></pure-xml-view>
<script>
const viewer = document.getElementById('my-viewer');
viewer.setXmlData('<root><item>Content</item></root>');
</script>
| Attribute | Type | Description |
|---|---|---|
data | string | The XML string to render |
| Method | Description |
|---|---|
setXmlData(string) | Sets the XML content programmatically |
expandAll() | Expands all nodes in the view |
collapseAll() | Collapses all nodes in the view |
The component doesn't emit any custom events currently.
While the component comes with built-in styling, you can customize its appearance using CSS variables or by targeting the shadow DOM parts in the future.
Here's a complete example of using the component:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>XML Viewer Demo</title>
<script src="path/to/pure-xml-view.js"></script>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
pure-xml-view {
margin-top: 20px;
border: 1px solid #ddd;
}
</style>
</head>
<body>
<h1>XML Viewer Demo</h1>
<pure-xml-view id="xml-viewer"></pure-xml-view>
<script>
const viewer = document.getElementById('xml-viewer');
const sampleXml = `<?xml version="1.0" encoding="UTF-8"?>
<library>
<!-- Book collection -->
<books>
<book id="b1">
<title>The Great Gatsby</title>
<author>F. Scott Fitzgerald</author>
<year>1925</year>
</book>
<book id="b2">
<title>To Kill a Mockingbird</title>
<author>Harper Lee</author>
<year>1960</year>
</book>
</books>
<magazines>
<magazine id="m1">
<title>National Geographic</title>
<frequency>Monthly</frequency>
</magazine>
</magazines>
</library>`;
viewer.setXmlData(sampleXml);
</script>
</body>
</html>
FAQs
XML viewer Web component
We found that pure-xml-view demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.