
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Use this when you need to loosen XML up and get it flowing. This is basically a wrapper for the excellent [xpath](https://www.npmjs.com/package/xpath) npm module.
Use this when you need to loosen XML up and get it flowing. This is basically a wrapper for the excellent xpath npm module.
Use xpath to extract the content you're looking for. It comes with sane defaults and utility methods, for example, defaulting to extracting the text content of the nodes, and a method for getting the first result.
Note: This module loosens things up - it does not throw errors for invalid xpaths. Instead, it will return an empty string for extractOne() and an empty array for extract(). The goal of this module is to help you write resilient code that can ingest 3rd party xml (that is open to unexpected changes) and parse the pieces you need.
Examples:
Extract the first result from your xpath expression. Now you don't have to worry about returning an array of results when you're expecting a string.
var xlax = require('xlax');
var music = new xlax('<music><artists><artist><name>TallyHall</name><yearFormed>2002</yearFormed></artist><artist><name>BenFoldsFive</name><yearFormed>1993</yearFormed></artist><artist><name>Wilco</name><yearFormed>1994</yearFormed></artist></artists></music>');
console.log(music.extractOne('//music/artists/artist/name/text()')); // Tally Hall
Return an array of instances of xlax for each match, so that you can extract the data from each result.
var xlax = require('xlax');
var music = new xlax('<music><artists><artist><name>Tally Hall</name><yearFormed>2002</yearFormed></artist><artist><name>Ben Folds Five</name><yearFormed>1993</yearFormed></artist><artist><name>Wilco</name><yearFormed>1994</yearFormed></artist></artists></music>');
var artists = music.extract('//music/artists/artist');
for (var i = 0; i < artists.length; i++) {
console.log(artists[i].extractOne('/artist/name/text()')); // each result
console.log(artists[i].extractOne('/artist/yearFormed/text()')); // each result
};
Iterate over each instance of xlax for each match, so that you can extract the data from each result.
var xlax = require('xlax');
var music = new xlax('<music><artists><artist><name>Tally Hall</name><yearFormed>2002</yearFormed></artist><artist><name>Ben Folds Five</name><yearFormed>1993</yearFormed></artist><artist><name>Wilco</name><yearFormed>1994</yearFormed></artist></artists></music>');
music.forEach('//music/artists/artist', function(node) { // grab each artist
console.log(node.toString()); // <artist><name>...
console.log(node.extractOne('/artist/name/text()')); // TallyHall, then Ben Folds Five, etc.
console.log(node.extractOne('/artist/yearFormed/text()')); // 2002, then 1993, etc.
});
Returns either the xml data passed into the object or the instance XML if called on the object(s) returned by xlax.extract().
Returns the length of the matched path passed into xlax.extract().
FAQs
Use this when you need to loosen XML up and get it flowing. This is basically a wrapper for the excellent [xpath](https://www.npmjs.com/package/xpath) npm module.
We found that xlax demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.