{"id":16531312,"url":"https://github.com/bjrmatos/read-xml","last_synced_at":"2025-07-10T06:09:39.104Z","repository":{"id":57348596,"uuid":"51343125","full_name":"bjrmatos/read-xml","owner":"bjrmatos","description":"Read a xml file respecting its encoding information","archived":false,"fork":false,"pushed_at":"2018-04-07T15:19:05.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-19T06:19:13.585Z","etag":null,"topics":["encoding","read-xml","xml"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bjrmatos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-09T02:52:17.000Z","updated_at":"2018-04-07T15:19:06.000Z","dependencies_parsed_at":"2022-08-31T18:01:50.728Z","dependency_job_id":null,"html_url":"https://github.com/bjrmatos/read-xml","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjrmatos%2Fread-xml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjrmatos%2Fread-xml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjrmatos%2Fread-xml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjrmatos%2Fread-xml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjrmatos","download_url":"https://codeload.github.com/bjrmatos/read-xml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241637616,"owners_count":19995007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["encoding","read-xml","xml"],"created_at":"2024-10-11T18:08:29.675Z","updated_at":"2025-03-03T09:21:41.928Z","avatar_url":"https://github.com/bjrmatos.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# read-xml\n[![NPM Version](http://img.shields.io/npm/v/read-xml.svg?style=flat-square)](https://npmjs.com/package/read-xml)\n[![License](http://img.shields.io/npm/l/read-xml.svg?style=flat-square)](http://opensource.org/licenses/MIT)\n[![Build Status](https://travis-ci.org/bjrmatos/read-xml.png?branch=master)](https://travis-ci.org/bjrmatos/read-xml)\n\n\u003e **Read a xml file respecting its encoding information**\n\n## Usage\n\nsimple-iso-8859-1.xml\n```xml\n\u003c?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\"?\u003e\n\u003ctest\u003e\n  \u003cvalue\u003eácentó y la letra ñ\u003cvalue\u003e\n\u003c/test\u003e\n```\n\nWithout this module the above xml file would be read incorrectly by the standard `fs` module, because node.js [only supports some encodings in its core](https://nodejs.org/dist/latest-v4.x/docs/api/buffer.html#buffer_buffer)\n\n```xml\n\u003c!-- output produced by fs.readFile/fs.readFileSync --\u003e\n\u003c?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\"?\u003e\n\u003ctest\u003e\n  \u003cvalue\u003e�cent� y la letra �\u003cvalue\u003e\n\u003c/test\u003e\n```\n\n### Basic API\n\n```js\n'use strict';\n\nvar fs = require('fs'),\n    path = require('path'),\n    xmlReader = require('read-xml');\n\nvar FILE = path.join(__dirname, 'test/xml/simple-iso-8859-1.xml');\n\n// pass a buffer or a path to a xml file\nxmlReader.readXML(fs.readFileSync(FILE), function(err, data) {\n  if (err) {\n    console.error(err);\n  }\n\n  console.log('xml encoding:', data.encoding);\n  console.log('Decoded xml:', data.content);\n});\n```\n\n### Streaming API\n\n```js\n'use strict';\n\nvar fs = require('fs'),\n    path = require('path'),\n    xmlReader = require('read-xml');\n\nvar FILE = path.join(__dirname, 'test/xml/simple-iso-8859-1.xml');\n\nvar decodedXMLStream = fs.createReadStream(FILE).pipe(xmlReader.createStream());\n\ndecodedXMLStream.on('encodingDetected', function(encoding) {\n  console.log('Encoding:', encoding);\n});\n\ndecodedXMLStream.on('data', function(xmlStr) {\n  console.log(xmlStr);\n});\n```\n\n## Supported encodings\n\nAll [encodings supported by iconv-lite](https://github.com/ashtuchkin/iconv-lite#supported-encodings)\n\n## License\nSee [license](https://github.com/bjrmatos/read-xml/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjrmatos%2Fread-xml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjrmatos%2Fread-xml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjrmatos%2Fread-xml/lists"}