【问题标题】:translate php id's to xml for helping clients with itunes将 php id 转换为 xml 以帮助客户使用 iTunes
【发布时间】:2012-03-20 11:51:04
【问题描述】:

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

我想要一个 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>

感谢您的宝贵时间。

【问题讨论】:

  • 你能提供 XML 模式吗?或者您是在问是否有适用于 iTunes 的?
  • 我刚刚用 XML 编辑了问题。
  • 我会说在DOMDocument 中加载它并使用XSLTProcessor::transformToXML,xsl 似乎并不难。

标签: php xml itunes


【解决方案1】:

可以使用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

并且要从父节点获取所有子节点,请使用此参考

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

我希望这能帮助你完成你的项目

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    • 2011-02-09
    • 1970-01-01
    • 2012-05-16
    • 2011-09-13
    • 2014-07-18
    相关资源
    最近更新 更多