hi....
i have an xml file which i've pasted below...

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
  <opensearch:Query searchTerms=""/>
  <opensearch:totalResults>1</opensearch:totalResults>
  <people>
    <person>
      <popularity>3</popularity>
      <name>Aamir Khan</name>
      <also_known_as>
      </also_known_as>
      <id>52763</id>
      <biography></biography>
      <known_movies>18</known_movies>
      <birthday></birthday>
      <birthplace></birthplace>
      <url>http://www.themoviedb.org/person/52763</url>
      <filmography>
        <movie name="Earth" id="7504" job="Actor" department="Actors" character="Dil Navaz" url="http://www.themoviedb.org/movie/7504" cast_id="2" poster="http://cf1.imgobject.com/posters/5ac/4bc91f50017a3c57fe00c5ac/earth-cover.jpg" adult="false" release="1998-09-16"/>
        <movie name="&#2352;&#2306;&#2327; &#2342;&#2375; &#2348;&#2360;&#2306;&#2340;&#2368;" id="7913" job="Actor" department="Actors" character="DJ" url="http://www.themoviedb.org/movie/7913" cast_id="2" poster="http://cf1.imgobject.com/posters/8e7/4bc91fc0017a3c57fe00c8e7/7913-cover.jpg" adult="false" release="2006-01-26"/>
        <movie name="Ghajini" id="14070" job="Actor" department="Actors" character="Sanjay Singhania" url="http://www.themoviedb.org/movie/14070" cast_id="12" poster="http://cf1.imgobject.com/posters/9e2/4bc9410e017a3c57fe01b9e2/ghajini-cover.jpg" adult="false" release="2008-12-24"/>
        <movie name="Dil Chahta Hai" id="14752" job="Actor" department="Actors" character="Akash" url="http://www.themoviedb.org/movie/14752" cast_id="5" poster="http://cf1.imgobject.com/posters/71a/4bc94480017a3c57fe01d71a/dil-chahta-hai-cover.jpg" adult="false" release="2001-07-24"/>
        <movie name="Luck By Chance" id="16344" job="Actor" department="Actors" character="Himself" url="http://www.themoviedb.org/movie/16344" cast_id="2" poster="http://cf1.imgobject.com/posters/25c/4bc94b5d017a3c57fe02125c/luck-by-chance-cover.jpg" adult="false" release="2009-03-27"/>
        <movie name="Akele Hum Akele Tum" id="16894" job="Actor" department="Actors" character="Rohit Kumar" url="http://www.themoviedb.org/movie/16894" cast_id="1" poster="http://cf1.imgobject.com/posters/0b0/4bc94db9017a3c57fe0220b0/akele-hum-akele-tum-cover.jpg" adult="false" release="1995-11-30"/>
        <movie name="Lagaan: Once Upon A Time In India" id="19666" job="Actor" department="Actors" character="Bhuvan" url="http://www.themoviedb.org/movie/19666" cast_id="5" poster="http://cf1.imgobject.com/posters/178/4bc95742017a3c57fe027178/lagaan-once-upon-a-time-in-india-cover.jpg" adult="false" release="2001-06-15"/>
        <movie name="3 Idiots" id="20453" job="Actor" department="Actors" character="Rancho" url="http://www.themoviedb.org/movie/20453" cast_id="5" poster="http://cf1.imgobject.com/posters/58b/4bc959a1017a3c57fe02858b/3-idiots-cover.jpg" adult="false" release="2009-12-25"/>
        <movie name="Mangal Pandey - The Rising" id="20496" job="Actor" department="Actors" character="Mangal Pandey" url="http://www.themoviedb.org/movie/20496" cast_id="1" poster="http://cf1.imgobject.com/posters/683/4bc959c2017a3c57fe028683/mangal-pandey-the-rising-cover.jpg" adult="false" release="2005-08-12"/>
        <movie name="Ishq" id="29988" job="Actor" department="Actors" character="Raja" url="http://www.themoviedb.org/movie/29988" cast_id="1" poster="http://cf1.imgobject.com/posters/5dd/4bc9743a017a3c57fe0355dd/ishq-cover.jpg" adult="false" release="1997-11-28"/>
        <movie name="Jo Jeeta Wohi Sikandar" id="33202" job="Actor" department="Actors" character="Sanjay Lal Sharma a.k.a Sanju" url="http://www.themoviedb.org/movie/33202" cast_id="8" poster="http://cf1.imgobject.com/posters/5cf/4bc97cb7017a3c57fe0395cf/jo-jeeta-wohi-sikandar-cover.jpg" adult="false" release="1992-05-22"/>
        <movie name="Andaaz Apna Apna" id="21458" job="Actor" department="Actors" character="" url="http://www.themoviedb.org/movie/21458" cast_id="2" poster="http://cf1.imgobject.com/posters/798/4bc95c20017a3c57fe029798/andaaz-apna-apna-cover.jpg" adult="false" release="1994-04-11"/>
        <movie name="Qayamat Se Qayamat Tak" id="27964" job="Actor" department="Actors" character="Raj" url="http://www.themoviedb.org/movie/27964" cast_id="1" poster="" adult="false" release="1988-07-09"/>
        <movie name="Jaane Tu Ya Jaane Na" id="14467" job="Producer" department="Production" character="" url="http://www.themoviedb.org/movie/14467" cast_id="2" poster="http://cf1.imgobject.com/posters/114/4c4f1db85e73d62ec1000114/jaane-tu-ya-jaane-na-cover.jpg" adult="false" release="2008-07-04"/>
        <movie name="PEEPLI [Live]" id="44549" job="Producer" department="Production" character="" url="http://www.themoviedb.org/movie/44549" cast_id="1" poster="http://cf1.imgobject.com/posters/07e/4c7c23d75e73d6474a00007e/peepli-live-cover.jpg" adult="false" release="2010-08-13"/>
        <movie name="Rangeela" id="21570" job="Actor" department="Actors" character="Munnaa" url="http://www.themoviedb.org/movie/21570" cast_id="5" poster="http://cf1.imgobject.com/posters/01b/4cae00095e73d652af00001b/rangeela-cover.jpg" adult="false" release="1900-01-01"/>
        <movie name="Hum Hain Rahi Pyar Ke" id="54814" job="Actor" department="Actors" character="Rahul Malhotra" url="http://www.themoviedb.org/movie/54814" cast_id="1" poster="http://cf1.imgobject.com/posters/3b5/4d3df15c7b9aa15bad0003b5/hum-hain-rahi-pyar-ke-cover.jpg" adult="false" release="1993-07-05"/>
        <movie name="Dhobi Ghat" id="54890" job="Producer" department="Production" character="" url="http://www.themoviedb.org/movie/54890" cast_id="2" poster="http://cf1.imgobject.com/posters/83e/4d48dd497b9aa13da700083e/dhobi-ghat-cover.jpg" adult="false" release="2011-01-21"/>
        <movie name="Dhobi Ghat" id="54890" job="Actor" department="Actors" character="Arun" url="http://www.themoviedb.org/movie/54890" cast_id="3" poster="http://cf1.imgobject.com/posters/83e/4d48dd497b9aa13da700083e/dhobi-ghat-cover.jpg" adult="false" release="2011-01-21"/>
      </filmography>
      <images>
        <image type="profile" url="http://cf1.imgobject.com/profiles/02a/4bc992d2017a3c182400002a/aamir-khan-original.jpg" size="original" width="300" height="450" id="4bc992d2017a3c182400002a"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/02a/4bc992d2017a3c182400002a/aamir-khan-profile.jpg" size="profile" width="185" height="278" id="4bc992d2017a3c182400002a"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/02a/4bc992d2017a3c182400002a/aamir-khan-thumb.jpg" size="thumb" width="45" height="68" id="4bc992d2017a3c182400002a"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/bd1/4cc2be977b9aa138da001bd1/aamir-khan-original.jpg" size="original" width="300" height="450" id="4cc2be977b9aa138da001bd1"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/bd1/4cc2be977b9aa138da001bd1/aamir-khan-profile.jpg" size="profile" width="185" height="278" id="4cc2be977b9aa138da001bd1"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/bd1/4cc2be977b9aa138da001bd1/aamir-khan-thumb.jpg" size="thumb" width="45" height="68" id="4cc2be977b9aa138da001bd1"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/bd5/4cc2bebf7b9aa138da001bd5/aamir-khan-original.jpg" size="original" width="300" height="450" id="4cc2bebf7b9aa138da001bd5"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/bd5/4cc2bebf7b9aa138da001bd5/aamir-khan-profile.jpg" size="profile" width="185" height="278" id="4cc2bebf7b9aa138da001bd5"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/bd5/4cc2bebf7b9aa138da001bd5/aamir-khan-thumb.jpg" size="thumb" width="45" height="68" id="4cc2bebf7b9aa138da001bd5"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/4a4/4d2174b97b9aa1280f0004a4/aamir-khan-original.jpg" size="original" width="400" height="618" id="4d2174b97b9aa1280f0004a4"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/4a4/4d2174b97b9aa1280f0004a4/aamir-khan-profile.jpg" size="profile" width="185" height="286" id="4d2174b97b9aa1280f0004a4"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/4a4/4d2174b97b9aa1280f0004a4/aamir-khan-thumb.jpg" size="thumb" width="45" height="70" id="4d2174b97b9aa1280f0004a4"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/172/4d32bbc87b9aa17b37005172/aamir-khan-original.jpg" size="original" width="500" height="700" id="4d32bbc87b9aa17b37005172"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/172/4d32bbc87b9aa17b37005172/aamir-khan-profile.jpg" size="profile" width="185" height="259" id="4d32bbc87b9aa17b37005172"/>
        <image type="profile" url="http://cf1.imgobject.com/profiles/172/4d32bbc87b9aa17b37005172/aamir-khan-thumb.jpg" size="thumb" width="45" height="63" id="4d32bbc87b9aa17b37005172"/>
      </images>
      <version>62</version>
      <last_modified_at>2011-02-14 09:11:59</last_modified_at>
    </person>
  </people>
</OpenSearchDescription>

i need to extract just the name, biography , filmography( with just movie name, job and url)....

the xslt code i wrote is as follows....

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="no" indent="yes"/>
<xsl:template match="/">
<people>
	<person>
		<name><xsl:value-of select="people/person/name"/></name>
		<biography><xsl:value-of select="people/person/biography"/></biography>
		<filmography>
			<xsl:for-each select="people/person/filmography/movie">
				<movie>
					<name><xsl:value-of select="/@name"/></name>
					<job><xsl:value-of select="/@job"/></job>
					<url><xsl:value-of select="/@url"/></url>
				</movie>
			</xsl:for-each>
		</filmography>
	</person>
</people>
</xsl:template>
</xsl:stylesheet>

but this just gives me the following output....

<?xml version="1.0" encoding="utf-8"?>
<people>
  <person>
    <name></name>
    <biography></biography>
    <filmography>
    </filmography>
  </person>
</people>

Please tell me where i'm going wrong........

Recommended Answers

All 2 Replies

think like xslt

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
	<xsl:output method="xml" omit-xml-declaration="no" indent="yes"/>
	<xsl:template match="/">
		<people>
			<person>
				<!--
		<name><xsl:value-of select="people/person/name"/></name>
		<biography><xsl:value-of select="people/person/biography"/></biography>
		<filmography>
			<xsl:for-each select="people/person/filmography/movie">
				<movie>
					<name><xsl:value-of select="/@name"/></name>
					<job><xsl:value-of select="/@job"/></job>
					<url><xsl:value-of select="/@url"/></url>
				</movie>
			</xsl:for-each>
		</filmography>-->
				<xsl:apply-templates select="OpenSearchDescription"/>
			</person>
		</people>
	</xsl:template>
	<xsl:template match="OpenSearchDescription">
		<xsl:apply-templates select="people"/>
	</xsl:template>
	<xsl:template match="people">
		<xsl:apply-templates select="person"/>
	</xsl:template>
	<xsl:template match="person">
		<name>
			<xsl:value-of select="name"/>
		</name>
		<biography>
			<xsl:apply-templates select="biography"/>
		</biography>
		<filmography>
			<xsl:apply-templates select="filmography"/>
		</filmography>
	</xsl:template>
	<xsl:template match="filmography">
		<xsl:apply-templates select="movie"/>
	</xsl:template>
	<xsl:template match="movie">
		<movi>
			<name>
				<xsl:value-of select="normalize-space(@name)"/>
			</name>
			<job>
				<xsl:value-of select="normalize-space(@job)"/>
			</job>
			<url>
				<xsl:value-of select="@url"/>
			</url>
		</movi>
	</xsl:template>
</xsl:stylesheet>
commented: thank you.... +1

thanks a lot... :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.