Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

atom-syndication-format

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atom-syndication-format

Parse Atom Syndication Format Feeds in XML

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

atom-syndication-format

Parse Atom Syndication Format Feeds in XML

install

npm install -S atom-syndication-format

basic usage

import { parse } from "atom-syndication-format";

// example from https://en.wikipedia.org/wiki/Atom_(web_standard)
const xml = `
<?xml version="1.0" encoding="utf-8"?>

<feed xmlns="http://www.w3.org/2005/Atom">

	<title>Example Feed</title>
	<subtitle>A subtitle.</subtitle>
	<link href="http://example.org/feed/" rel="self" />
	<link href="http://example.org/" />
	<id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id>
	<updated>2003-12-13T18:30:02Z</updated>
	
	
	<entry>
		<title>Atom-Powered Robots Run Amok</title>
		<link href="http://example.org/2003/12/13/atom03" />
		<link rel="alternate" type="text/html" href="http://example.org/2003/12/13/atom03.html"/>
		<link rel="edit" href="http://example.org/2003/12/13/atom03/edit"/>
		<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
        <published>2003-11-09T17:23:02Z</published>
		<updated>2003-12-13T18:30:02Z</updated>
		<summary>Some text.</summary>
		<content type="xhtml">
			<div xmlns="http://www.w3.org/1999/xhtml">
				<p>This is the entry content.</p>
			</div>
		</content>
		<author>
			<name>John Doe</name>
			<email>johndoe@example.com</email>
		</author>
	</entry>

</feed>	
`;

parse(xml);
{
  "id": "urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6",
  "title": "Example Feed",
  "subtitle": "A subtitle.",
  "updated": 2003-12-13T18:30:02Z,  // JavaScript Date Object
  "author": {
    "name": "John Doe",
    "email": "johndoe@example.com"
  },
  "links": [
    {
      "href": "http://example.org/feed/",
      "rel": "self"
    },
    {
      "href": "http://example.org/"
    }
  ],
  "entries": [
    {
      "xml": "<entry>\n\t\t<title>Atom-Powered Robots Run Amok</title>\n\t\t...", // the raw un-parsed xml for the entry
      "id": "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a",
      "title": "Atom-Powered Robots Run Amok",
      "published": 2003-11-09T17:23:02Z, // JavaScript Date Object
      "updated": 2003-12-13T18:30:02Z, // JavaScript Date Object
      "content": {
        "content": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n\t\t\t\t<p>This is the entry content.</p>\n\t\t\t</div>",
        "type": "xhtml"
      },
      "summary": {
        "summary": "Some text."
      },
      "links": [
        {
          "href": "http://example.org/2003/12/13/atom03"
        },
        {
          "href": "http://example.org/2003/12/13/atom03.html",
          "rel": "alternate",
          "type": "text/html"
        },
        {
          "href": "http://example.org/2003/12/13/atom03/edit",
          "rel": "edit"
        }
      ]
    }
  ]
}

advanced usage

To turn off conversation of dates into JavaScript date objects, pass in raw: true.

parse(xml, { raw: true });

references

Keywords

FAQs

Package last updated on 08 Apr 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc