我是angular2的新手,希望將XML轉換爲json。我使用get方法來接收它。每當我直接在json接收數據時發佈我。Angular2:獲取XML數據並將其轉換爲JSON
請幫助我的工作示例。下面是我的XML
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
<catalog>
你說的'問題,我在JSON directly.'每次我收到的數據,如果你已經收到JSON數據,爲什麼你需要解析XML? – Dummy
https://github.com/Leonidas-from-XIV/node-xml2js – cartant
@Dummy這次我想出了具有XML數據而不是JSON的Web服務 – Jay