简体   繁体   English

将XML文件放入Parse.Com类

[英]Getting XML File Into Parse.Com Class

I am trying to take a directory that is currently an RSS in XML format, and upload it as a class into Parse.com. 我正在尝试获取当前为XML格式的RSS的目录,并将其作为类上传到Parse.com。 The structure of the XML is: 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 allows importing of JSON or CSV Files. Parse.com允许导入JSON或CSV文件。 I have used an online converter for the JSON file, but when I import it, everything comes out as one row in the Parse table, instead of one row for each item. 我已经为JSON文件使用了在线转换器,但是当我导入它时,所有内容在Parse表中显示为一行,而不是每个项目一行。 It basically puts all after results into one line. 它基本上将所有结果放在一行中。 Suggestions? 有什么建议吗?

The format of my JSON is: 我的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 is only interested in the objects itself, my guess is you will have to manually edit your JSON in TextEdit or something similar. Parse只对对象本身感兴趣,我猜您将不得不在TextEdit或类似工具中手动编辑JSON。 Which could take just as long as manually creating the objects in the console yourself. 这可能需要花费与您自己在控制台中手动创建对象一样长的时间。

So if you just want all the books as objects you can simply erase the erroneous text and just leave: 因此,如果您只想将所有书籍作为对象,则只需删除错误的文本并离开即可:

{"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