2012-03-01 48 views
1

我在想這很容易,但是我找不到任何東西。將php id轉換爲xml以幫助客戶與itunes

我想要一個php頁面,我的客戶可以編輯和翻譯成itunes xml文件。我想我的網頁不需要是PHP,如果這會妨礙翻譯

有沒有辦法做到這一點?

這是代碼。還有很多,但你得到了jist。

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

謝謝你的時間。

+0

你所能提供的XML模式?或者你問是否有iTunes適用於iTunes? – Jakub 2012-03-01 22:51:35

+0

我剛剛用XML編輯了這個問題。 – BostonBB 2012-03-01 22:57:15

+0

我會說它加載在'DOMDocument'並使用'XSLTProcessor :: transformToXML',xsl似乎並不難。 – Wrikken 2012-03-01 23:05:40

回答

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

並讓所有的子節點從父用這個全球化志願服務青年

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

我希望這將幫助你,使你的項目