簡體   English   中英

將XML文件放入Parse.Com類

[英]Getting XML File Into Parse.Com Class

我正在嘗試獲取當前為XML格式的RSS的目錄,並將其作為類上傳到Parse.com。 XML的結構為:

<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <atom:link rel="self" type="application/rss+xml" href="http://www.316apps.com/NewallaSermons/Directory.xml" />
        <lastBuildDate>Thu, 16 Aug 2012 09:26:14 -0500</lastBuildDate>
        <title>Newalla Church of Christ Directory</title>
        <description><![CDATA[Directory of Members for Newalla Church of Christ]]></description>

        <language>en</language>
        <copyright>2012 Newalla Church of Christ</copyright>

        <item>
            <title>Last Name</title>
            <description>First Name</description>
            <author>Address</author>
            <comments>Phone Number</comments>
            <link></link>
<pubDate>Sun, 09 Sep 2012 18:00:00 -0500</pubDate>
        </item>
        <item>
            <title>Another Last Name</title>
            <description>Another First Name</description>
            <author>Another Address</author>
            <comments>Another Phone Number</comments>
            <link></link>
<pubDate>Sun, 09 Sep 2011 18:00:00 -0500</pubDate>
        </item>

    </channel>
</rss>

Parse.com允許導入JSON或CSV文件。 我已經為JSON文件使用了在線轉換器,但是當我導入它時,所有內容在Parse表中顯示為一行,而不是每個項目一行。 它基本上將所有結果放在一行中。 有什么建議嗎?

我的JSON格式為:

{
    "results": [
        {
            "rss": {
                "channel": {
                    "link": [
                        {
                            "_rel": "self",
                            "_type": "application/rss+xml",
                            "_href": "http://www.316apps.com/NewallaSermons/Directory.xml",
                            "__prefix": "atom"
                        },
                        "http://www.316apps.com"
                    ],
                    "lastBuildDate": "Thu, 16 Aug 2012 09:26:14 -0500",
                    "title": "Newalla Church of Christ Directory",
                    "author": {
                        "__prefix": "itunes",
                        "__text": "Newalla Church of Christ"
                    },
                    "generator": "Podcast Maker v1.4.1 - http://www.lemonzdream.com/podcastmaker",
                    "description": {
                        "__cdata": "Directory of Members for Newalla Church of Christ"
                    },
                    "summary": {
                        "__prefix": "itunes",
                        "__text": "Directory of Members for Newalla Church of Christ"
                    },
                    "language": "en",
                    "copyright": "2012 Newalla Church of Christ",
                    "item": [
                        {
                            "title": "First Name",
                            "description": "Last Name",
                            "author": "Address",
                            "comments": "Phone",
                            "link": "",
                            "pubDate": "Sun, 09 Sep 2012 18:00:00 -0500"
                        },
                        {
                            "title": "Another Last Name",
                            "description": "Another First",
                            "author": "Another Address",
                            "comments": "Another Phone",
                            "link": "",
                            "pubDate": "Sun, 09 Sep 2011 18:00:00 -0500"
                        },

                "_xmlns:itunes": "http://www.itunes.com/dtds/podcast-1.0.dtd",
                "_xmlns:atom": "http://www.w3.org/2005/Atom",
                "_version": "2.0"
            }
        }
    ]
}

Parse只對對象本身感興趣,我猜您將不得不在TextEdit或類似工具中手動編輯JSON。 這可能需要花費與您自己在控制台中手動創建對象一樣長的時間。

因此,如果您只想將所有書籍作為對象,則只需刪除錯誤的文本並離開即可:

{"results" : [
    {
        "title": "First Name",
        "description": "Last Name",
        "author": "Address",
        "comments": "Phone",
        "link": "",
        "pubDate": "Sun, 09 Sep 2012 18:00:00 -0500"
    },
    {
        "title": "Another First Name",
        "description": "Another Last Name",
        "author": "Another Address",
        "comments": "Another Phone",
        "link": "",
        "pubDate": "Sun, 09 Sep 2012 18:00:00 -0500"
    }
]}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM