我是XSL的新手,我试图获取标签的值
我有一个像这样的文件
<?xml version="1.0" encoding="UTF-8"?> <MPD
xmlns:xsi="http://www.w3.org/2001/XMLSchema"
xmlns="urn:mpeg:mpegB:schema:DASH:MPD:DIS2011"
xsi:schemaLocation="urn:mpeg:mpegB:schema:DASH:MPD:DIS2011"
profiles= "urn:mpeg:mpegB:profile:dash:isoff-basic-on-demand:cm"
type="OnDemand"
mediaPresentationDuration="PT5M0.08S"
minBufferTime="PT10.00S">
<Period>
<Group segmentAlignmentFlag="true" mimeType="video/mp4"> <Representation mimeType="video/mp4" width="854" height="480"
startWithRAP="true" bandwidth="516739" minBufferTime="2000">
<SegmentInfo duration="PT2.00S">
<InitialisationSegmentURL sourceURL="http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel_trailer_2k_480p24_1200kbit_dash.mp4"/>
<Url sourceURL="http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel1.m4s"/>
<Url sourceURL="http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel2.m4s"/>
<Url sourceURL="http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel3.m4s"/>
<Url sourceURL="http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel4.m4s"/>
<Url sourceURL="http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel5.m4s"/>
</SegmentInfo> </Representation>
</Group>
</Period> </MPD>
我想像这样获得Url sourceURL的值
http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel1.m4s
有人可以帮助我吗?
答案 0 :(得分:1)
此样式表:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="descendant::*">
<xsl:if test="@sourceURL">
<URL><xsl:value-of select="@sourceURL"/></URL>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
产生
<URL>http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel_trailer_2k_480p24_1200kbit_dash.mp4</URL>
<URL>http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel1.m4s</URL>
<URL>http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel2.m4s</URL>
<URL>http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel3.m4s</URL>
<URL>http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel4.m4s</URL>
<URL>http://jakjak.dit.upm.es/mpd/sintel_1200kbit/sintel5.m4s</URL>