declare @idoc int
declare @doc char(8000)
set @doc= '<SchoolRecord>
<School ID="1" Name="A1">
<Location ID="1" City="Karachi" Country = "Pakistan">
<Area ID="1" Type="Primary" NoOfStudent="300">
<Student ID="1" Name="Kashif" FatherName="Alam" />
<Student ID="2" Name="Kamran" FatherName="Alam" />
<Student ID="3" Name="Mujahid" FatherName="Hasan" />
<Student ID="4" Name="Ishfaaq" FatherName="Hussain" />
</Area>
<Area ID="2" Type="Secondary" NoOfStudent="100">
<Student ID="5" Name="Atif" FatherName="Alam" />
<Student ID="6" Name="Amir" FatherName="Alam" />
<Student ID="7" Name="Rehan" FatherName="Tariq" />
<Student ID="8" Name="Jamil" FatherName="Muhammad" />
</Area>
</Location>
<Location ID="2" City="Lahore" Country = "Pakistan">
<Area ID="3" Type="Primary" NoOfStudent="200">
<Student ID="9" Name="Owais" FatherName="Ali" />
<Student ID="10" Name="Ibrahim" FatherName="Muhammad" />
<Student ID="11" Name="Adam" FatherName="Khan" />
<Student ID="12" Name="Ismayil" FatherName="Sheikh" />
</Area>
<Area ID="4" Type="Secondary" NoOfStudent="70">
<Student ID="13" Name="Yousuf" FatherName="Nawaz" />
<Student ID="14" Name="Hannan" FatherName="Baksh" />
<Student ID="15" Name="Ishaq" FatherName="Ali" />
<Student ID="16" Name="Talha" FatherName="Jamil" />
</Area>
</Location>
</School>
<School ID="2" Name="A2">
<Location ID="3" City="Riyadh" Country = "SaudiArabia">
<Area ID="5" Type="Primary" NoOfStudent="100">
<Student ID="17" Name="Umer" FatherName="Hantool" />
<Student ID="18" Name="Saud" FatherName="Herabi" />
<Student ID="19" Name="Khalid" FatherName="Shawan" />
<Student ID="20" Name="Muhammad" FatherName="Zharani" />
</Area>
<Area ID="6" Type="Secondary" NoOfStudent="50">
<Student ID="21" Name="Faisal" FatherName="Riaz" />
<Student ID="22" Name="Aaiz" FatherName="Kazran" />
<Student ID="23" Name="Fahad" FatherName="Talabi" />
<Student ID="24" Name="Homoud" FatherName="Alfaiz" />
</Area>
</Location>
<Location ID="4" City="Dubai" Country = "Emirates">
<Area ID="7" Type="Primary" NoOfStudent="900">
<Student ID="25" Name="Owais" FatherName="Qerni" />
<Student ID="26" Name="Ibrahim" FatherName="Asfiyan" />
<Student ID="27" Name="Faizan" FatherName="Ahsan" />
<Student ID="28" Name="Safan" FatherName="Ahsan" />
</Area>
<Area ID="8" Type="Secondary" NoOfStudent="500">
<Student ID="29" Name="Fawad" FatherName="Hussain" />
<Student ID="30" Name="Tuaha" FatherName="Syed" />
<Student ID="31" Name="Umer" FatherName="Hamayun" />
<Student ID="32" Name="Tariq" FatherName="Aslam" />
</Area>
</Location>
</School>
</SchoolRecord>'
exec sp_xml_preparedocument @idoc OUTPUT, @doc

select ID,Name,School FROM
openxml (@idoc,'/SchoolRecord/School/Location/Area/Student',3)
with (
ID int'@ID',
Name varchar(30)'@Name',
School varchar(30)'../../../@Name'
)


" i need to get the results where location is of karachi only"
i am feeling difficulty in maiking query with 'where' clause in open xml. kindly help me and do post me the reply at my email id given below.

syedwaqihaider
@yahoo

thanx a lot