[MarkLogic Dev General] Search XML files by an Attribute
G. Ken Holman
gkholman at CraneSoftwrights.com
Mon Oct 12 08:52:53 PDT 2009
At 2009-10-12 21:11 +0530, Jamin wrote:
>I would like to search an XML file by an Attribute of an element and
>the result I get should be the element and its contents only.
>For e.g.:
>File : My.xml
><bookstore>
> <book lang="English">Learning XQuery </book>
> <book lang="French">French Culture</book>
> <book lang="Italian">Italian Food</book>
></bookstore>
>
>Now when I search for attribute "English" the result I get should
>be like this
You don't mention that the name of the element is important to
you. I realize in your simple example there are only "book"
elements, but you are asking for a search only based on the attribute's value.
>"<book lang="English">Learning XQuery </book>" only and not the
>entire XML file.
This finds all elements of any name that have a lang= attribute of "English":
//*[@lang='English']
I hope this helps.
. . . . . . . . . Ken
--
Upcoming: hands-on code list, UBL, XSLT, XQuery and XSL-FO classes
in Copenhagen Denmark and Washington DC USA, October/November 2009
Interested in other classes? http://www.CraneSoftwrights.com/c/i/
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/c/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman mailto:gkholman at CraneSoftwrights.com
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/c/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
More information about the General
mailing list