0.0.1 • Published 1 year ago

xml-fns v0.0.1

Weekly downloads
-
License
CC0-1.0
Repository
github
Last release
1 year ago

xml-fns

Higher Level XML Utility Functions

install

npm install xml-fns

usage

findTagText

import { findTagText } from "xml-fns/findTagText.js"

const xml = `
<item>
  <title>
    My Article
  </title>
</item>
`;

// by tag name
findTagText(xml, "title"); // "My Article"

hasTag

import { hasTag } from "xml-fns/hasTag.js"

const xml = `
<item>
  <title>My Article</title>
</item>
`;

// by tag name
hasTag(xml, "title"); // true

// by tag path
hasTag(xml, ["item", "title"]); // true

hasAllTags

import { hasAllTags } from "xml-fns/hasAllTags.js"

const xml = `
<item>
  <title>My Article</title>
  <geo:lat>5.5319</geo:lat>
  <geo:long>95.8972</geo:long>  
</item>
`;

// by tag names
hasAllTags(xml, ["geo:lat", "geo:long"]); // true

// by tag paths
hasAllTags(xml, [["item", "geo:lat"], ["item", "geo:long"]]); // true
0.0.1

1 year ago