Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
react-xml-parser
Advanced tools
XML parser for react-native
Weekly downloads
Readme
A simple and user-friendly XML parser for React-native developers. This library's goal is to parse simple XML responses, from and to string.
$ npm install react-xml-parser
XML:
<?xml version='1.0' encoding='utf-8'?>
<Library>
<Books count='1'>
<Book id='1'>
<Name>Me Before You</Name>
<Author>Jojo Moyes</Author>
</Book>
</Books>
<Music count=1>
<CD id='2'>
<Name>Houses of the Holy</Name>
<Artist>Led Zeppelin</Artist>
</CD>
</Music>
</Library>
JS:
var XMLParser = require('react-xml-parser');
var xml = new XMLParser().parseFromString(xmlText); // Assume xmlText contains the example XML
console.log(xml);
console.log(xml.getElementsByTagName('Name'));
Output:
// XML parsing response
{
name: 'Library', attributes: {}, value: '', children: [
{
name: 'Books', attributes: { count: '1' }, value: '', children: [
{
name: 'Book', attributes: { id: '1' }, value: '', children: [
{
name: 'Name', attributes: {}, value: 'Me Before You', children: []
}, {
name: 'Author', attributes: {}, value: 'Jojo Moyes', children: []
}
]
}
]
},
{
name: 'Music', attributes: { count: '1' }, value: '', children: [
{
name: 'CD', attributes: { id: '2' }, value: '', children: [
{
name: 'Name', attributes: {}, value: 'Houses of the Holy', children: []
}, {
name: 'Artist', attributes: {}, value: 'Led Zeppelin', children: []
}
]
}
]
}
]
}
// getElementsByTagName response
[
{
name: 'Name', attributes: {}, value: 'Me Before You', children: []
}, {
name: 'Name', attributes: {}, value: 'Houses of the Holy', children: []
}
]
Methods that are currently supported:
parseFromString(string): Returns an XML object as described in the example output that represents the input text.
toString(XML object): Returns text representation of an input XML.
getElementsByTagName(string): Returns all tags with the same name as the method's input string (case-insensitive). for all possible tags, use '*' as input.
ISC
FAQs
XML parser for react-native
The npm package react-xml-parser receives a total of 9,831 weekly downloads. As such, react-xml-parser popularity was classified as popular.
We found that react-xml-parser 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
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.