As a newcomer to the world of XSLT, I want to filter an XML document based on the attribute value, and then retrieve the elements containing such attributes and discard all others.
Sample XML doc
<Items>
<item1>
<first>Lorem ipsum</first>
<second att="abc"> dolor sit amet</title>
<third>consectetur adipiscing elit, sed do eiusmod tempor</third>
<forth>ncididunt ut labore et dolore</forth>
</item1>
<item2>
<first att="def">Sed ut perspiciatis</first>
<second>unde omnis iste natus.</title>
<third att="ghi">error sit voluptatem accusantium</third>
<forth>doloremque laudantium</forth>
</item2>
<item3>
<first att="mno">At vero eos et </first>
<second>accusamus et iust</title>
<third>odio dignissimos ducimus qui blanditiis p</third>
<forth att="jkl">voluptatum deleniti atque</forth>
</item3>
<item4>
<first>Et harum quidem</first>
<second att="abc">rerum </title>
<third att="xyz"> soluta nobis est eligendi </third>
<forth> Temporibus aut</forth>
</item4>
And I want to have this result (att="abc" is desired ):
<Items>
<item1>
<first>Lorem ipsum</first>
<second att="abc"> dolor sit amet</title>
<third>consectetur adipiscing elit, sed do eiusmod tempor</third>
<forth>ncididunt ut labore et dolore</forth>
</item1>
<item4>
<first>Et harum quidem</first>
<second att="abc">rerum </title>
<third att="xyz"> soluta nobis est eligendi </third>
<forth> Temporibus aut</forth>
</item4>
</items>
I've found a similar solution here but it doesn't work for me. Also, I think I should use for-each expression but I don't know how to do that.
No comments:
Post a Comment