将php id转换为xml,以帮助客户使用itunes

时间:2012-03-01 22:49:26

标签: php xml itunes

我认为这很容易,但我找不到任何东西。

我想要一个我的客户可以编辑的php页面并将其转换为itunes xml文件。我想我的页面不需要是php,如果这会阻碍翻译

有办法做到这一点吗?

这是代码。还有很多,但是你得到了这个小说。

<div id="iTunes">
<p id="title" class="cms-editable">Your Channel tile</p>
<p id="author" class="cms-editable">Authors Name</p>
<p id="summary" class="cms-editable">Short Summary</p>
<p id="description" class="cms-editable">Short Description</p>

<div id="item" class="cms-repeatable" >
<p id="item-title" class="cms-editable">Your Podcast Title</p>
<p id="item-author" class="cms-editable">Podcast Author</p>
<p id="item-enclosure" class="cms-editable">http://www.Domain.org/podcast.mp3</p>

</div>
</div>

XML看起来像这样。

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<channel>
<title>Your Channel tile</title>
<itunes:author>Authors Name</itunes:author>
<itunes:summary>Short Summary</itunes:summary>
<description>Short Description</description>
<item>
<title>Your Podcast Title</title>
<itunes:author>Podcast Author</itunes:author>
<enclosure url="http://www.Domain.org/podcast.mp3" length="" type="audio/x-mp3" />
</item>
</channel>
</rss>

感谢您的时间。

1 个答案:

答案 0 :(得分:0)

您可以使用jquery并生成xml

例如,您可以像这样生成xml

var xml = $('<?xml version="1.0"?><foo><bar></bar><bar></bar></foo>'); // Your xml
var xmlCont = $('<xml>'); // You create a XML container
xmlCont.append(xml); // You append your XML to the Container created in the main document

// Now you can append without problems to you xml
xmlCont.find('foo bar:first').append('<div />');

xmlCont.find('foo bar div'); // Test so you can see it works

你可以使用这个jquery命令获取所有元素

$("#item > p").each(function() {
       //Create xml here 
    });

这也是一个例子,请参考这里的xml创建

writing XML files with jQuery

并且从父级获取所有子节点使用此referance

jQuery - get all divs inside a div with class ".container"

我希望这可以帮助您制作项目