@wsdot/geospatial-metadata
v0.1.0
Published
A library for parsing and converting Geospatial metadata XML
Downloads
5
Maintainers
Readme
geospatial-metadata
A JavaScript library for parsing and converting Geospatial Metadata.
Features
- Convert XML document into JSON.
- Convert XML document into HTML.
- Contact information uses microformats classes.
Installation
npm install @wsdot/geospatial-metadata
Use
import { toHtmlFragment } from "@wsdot/geospatial-metadata";
/**
* Gets a metadata XML document, converts it to an HTMLDocumentFragment,
* then appends the fragment to the document body.
* @param {string} url - Metadata URL.
* @returns {Promise}
*/
async function getMetadataHtml(url) {
const response = await fetch(url);
const xml = await response.text();
const frag = toHtmlFragment(xml);
document.body.append(frag);
}
const url = "https://data.wsdot.wa.gov/arcgis/rest/services/Shared/CityLimits/MapServer/exts/LayerMetadata/metadata/0?f=xml";
getMetadataHtml(url).then(() => {
console.log(`Successfully added metadata from ${url}.`);
}, error => {
console.error(`Error adding metadata from ${url}`, error);
});