【发布时间】:2017-11-16 12:17:38
【问题描述】:
我有几个 XML 格式的文件。每个文件包含 XML 标头和大约 15-20 项。我想将这些文件存储在我认为以 JSON 格式存储数据的 MongoDB 中。这是我要存储在 MongoDB 中的数据示例。
<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">
<channel>
<title>Channel Title</title>
<link>Channel link</link>
<description>Channel desc</description>
<!-- Item 1 -->
<item>
<title>Your Title</title>
<link>Your link</link>
<pubDate>Published date</pubDate>
<description>Your description</description>
</item>
<!-- Item 2 -->
<item>
<title>Your Title</title>
<link>Your link</link>
<pubDate>Published date</pubDate>
<description>Your description</description>
</item>
</channel>
</rss>
如何进行?谁能帮助使用一些示例和示例代码如何将这些数据存储在 MongoDB 中? 注意:我将使用 Node/Javascript 进行 CRUD 操作。
编辑:
存储数据的过程就像有一个表格,您选择一个类别(频道名称,如频道标题),然后将<item> 添加到该频道。但整个数据将存储在 MongoDB 中。
【问题讨论】:
-
让你眼前一亮。
-
你的代码在哪里?
-
理解题有什么困惑吗?让我添加更多细节。
标签: javascript node.js xml mongodb