0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

お知らせ

本記事はれのらりブログの一部を修正して再投稿したものです。
最新の情報や作成当時の情報は、れのらりブログからご確認いただけます。

動作環境

名前 バージョン
Node.js 17.3.1
npm 8.5.1
xml2js 0.4.23

必須モジュール

今回使用するのはxml2jsです。

npm install xml2js

ソースコード

file.xmlを文字コードutf-8として読み込み、コンソールにログとしてオブジェクトを表示します。

const { readFileSync } = require("fs");
const { parseString } = require("xml2js");

parseString(readFileSync("file.xml", "utf-8"), (err, result) => {
  if (err) {
    console.error(err);
  } else {
    console.log(result);
  }
});
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?