View Single Post
 
Old December 20th, 2007, 03:06 AM
aintvoguish aintvoguish is offline
Registered User
 
Join Date: Dec 2007
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Extracting portion of XML ** Need help asap**

I have a requirement where i need to parse/extract a portion of xml based on certain variable which is available in same xml.

for ex:

<booklist>
    <book>
        <category>Fiction</category>
        <titleA>DaysMurder</titleA>
        <price>
            <cents>10</cents>
            <dollar>12</dollar>
        </price>
        <amount>2</amount>
    </book>
    <book1>
        <category>Fiction1</category>
        <titleA>DaysMurder1</titleA>
        <price>
            <cents>101</cents>
            <dollar>121</dollar>
        </price>
        <amount>21</amount>
    </book1>
    <book2>
        <category>Fiction2</category>
        <titleA>DaysMurder2</titleA>
        <price>
            <cents>102</cents>
            <dollar>122</dollar>
        </price>
        <amount>22</amount>
    </book2>
    <value>book2</value>
</booklist>


In the above example having list of books, i need to extract book node based on element value which appears in the end. In this case my output should look like

    <book2>
        <category>Fiction2</category>
        <titleA>DaysMurder2</titleA>
        <price>
            <cents>102</cents>
            <dollar>122</dollar>
        </price>
        <amount>22</amount>
    </book2>

please suggest a way to accomplish this thing, if some one can reply with an xslt that will be really helpful