[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A JavaScript library for parsing and converting Geospatial metadata XML

License

Notifications You must be signed in to change notification settings

WSDOT-GIS/geospatial-metadata

Repository files navigation

geospatial-metadata

A JavaScript library for parsing and converting Geospatial Metadata.

Try me!

npm npm npm GitHub

Features

  • Convert XML document into JSON.
  • Convert XML document into HTML.

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);
}

// URL to retrieve XML metadata via ArcGIS Server.
const url = "https://data.wsdot.wa.gov/arcgis/rest/services/Shared/BridgeData/MapServer/2/metadata/";

getMetadataHtml(url).then(() => {
    console.log(`Successfully added metadata from ${url}.`);
}, error => {
    console.error(`Error adding metadata from ${url}`, error);
});

Resources