2012-03-21 6 views
0

가 여기에 XML의 :XSLT를 사용하여 XML 피드를 변환하는 방법은 무엇입니까?

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?> 
    <feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"> 
     <title>Rated Images</title> 
     <link rel="self" href="http://mirror/blog/?feed=photos&amp;lang=en" /> 
     <link rel="alternate" type="text/html" href="http://mirror/blog"/> 
     <icon>http://mirror/avatars/sterling-adventures.jpg</icon> 
     <subtitle>Just another WordPress site</subtitle> 
     <updated>2012-03-20T09:50:48+00:00</updated> 
     <generator uri="http://mirror/">Test</generator> 
<entry> 
    <title>Les Houches</title> 
    <link rel='alternate' type='text/html' href='http://mirror/blog/2011/12/28/les-houches/' /> 
    <published>2011-12-28T11:29:29+00:00</published> 
    <id>http://mirror/blog/wp-content/uploads/2011/12/IMG_8830.jpg</id> 
    <updated>2011-12-28T11:29:29+00:00</updated> 
    <content type='html'> 
     &lt;p&gt;&lt;a href=&quot;http://mirror/blog/author/admin/&quot;&gt;admin&lt;/a&gt; posted a photo from Les Houches:&lt;/p&gt; 
     &lt;p&gt;&lt;a href=&quot;http://mirror/blog/2011/12/28/les-houches/&quot; title=&quot;Les Houches&quot;&gt;&lt;img src=&quot;http://mirror/blog/wp-content/uploads/2011/12/IMG_8830.jpg&quot; width=&quot;138&quot; height=&quot;160&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt; 
    </content> 
    <author> 
     <name>admin</name> 
     <uri>http://mirror/blog/author/admin/</uri> 
    </author> 
    <link rel='enclosure' type='image/jpeg' href='http://mirror/blog/wp-content/uploads/2011/12/IMG_8830.jpg' /> 
</entry> 
</feed> 

그리고 내가 돌아올하려는 모든 링크 요소의 href 속성이며, 다른 모든 폐기 할 수있다. 즉 링크 HREF해야 아웃의 각 라인은 ...

누군가가 나에게 적합한 XSLT를 구축 할 수

희망 ...

:-)

답변

2

는 아마도이 도움이 될 것입니다

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:atom="http://www.w3.org/2005/Atom"> 
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> 
    <xsl:template match="/"> 
     <output> 
     <xsl:for-each select="/atom:feed/atom:entry/atom:link"> 
      <xsl:value-of select="@href"/> 
     </xsl:for-each> 
     </output> 
    </xsl:template> 
</xsl:stylesheet> 
+0

오, XSL 2.0의 고급 스러움! – Borodin

+0

이것은 XSLT 1.0에서도 100 % 작동합니다. 여기에는 특별한 것이 없습니다. –

+0

예 알아요 - 그냥 피곤 하네 :) – Borodin

관련 문제