Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
xml-parser-xo
Advanced tools
An XML parser based on xml-parser.
$ npm install xml-parser-xo
import xmlParser from 'xml-parser-xo';
var xml = `<?xml version="1.0" encoding="utf-8"?>
<!-- Load the stylesheet -->
<?xml-stylesheet href="foo.xsl" type="text/xsl" ?>
<!DOCTYPE foo SYSTEM "foo.dtd">
<foo><![CDATA[some text]]> content</foo>`;
xmlParser(xml);
{
"declaration": {
"type": "ProcessingInstruction",
"attributes": {"version": "1.0", "encoding": "utf-8"}
},
"root": {
"type": "Element",
"name": "foo",
"attributes": {},
"children": [
{"type": "CDATA", "content": "<![CDATA[some text]]>"},
{"type": "Text", "content": " content"}
]
},
"children": [
{"type": "Comment", "content": "<!-- Load the stylesheet -->"},
{"type": "ProcessingInstruction", "attributes": {"href": "foo.xsl", "type": "text/xsl"}},
{"type": "DocumentType", "content": "<!DOCTYPE foo SYSTEM \"foo.dtd\">"},
{
"type": "Element",
"name": "foo",
"attributes": {},
"children": [
{"type": "CDATA", "content": "<![CDATA[some text]]>"},
{"type": "Text", "content": " content"}
]
}
]
}
filter
: Function to filter out unwanted nodes by returning false
.
function(node) => boolean
() => true
strictMode
: True to throw an error when parsing XML document with invalid content like mismatched closing tags.
boolean
false
import xmlParser from 'xml-parser-xo';
const xml = `<?xml version="1.0" encoding="utf-8"?>
<!-- Load the stylesheet -->
<?xml-stylesheet href="foo.xsl" type="text/xsl" ?>
<!DOCTYPE foo SYSTEM "foo.dtd">
<foo><![CDATA[some text]]> content</foo>`;
xmlParser(xml, {
filter: (node) => {
return node.type === 'Element' || node.type === 'Text';
}
});
{
"declaration": {
"type": "ProcessingInstruction",
"attributes": {"version": "1.0", "encoding": "utf-8"}
},
"root": {
"type": "Element",
"name": "foo",
"attributes": {},
"children": [
{"type": "Text", "content": " content"}
]
},
"children": [
{
"type": "Element",
"name": "foo",
"attributes": {},
"children": [
{"type": "Text", "content": " content"}
]
}
]
}
MIT
FAQs
Parse a XML string into a proprietary syntax tree
The npm package xml-parser-xo receives a total of 166,025 weekly downloads. As such, xml-parser-xo popularity was classified as popular.
We found that xml-parser-xo demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.