Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: XML Search?

  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XML Search?

    Hi all,

    Im new to the forum so please forgive me if a do somthing wrong

    Ok im fairly new to Javascript and Ajax but im in the middle of building a CD based application running through html etc. I have a large xml file that is used to populate different fields in a form....

    such as a Country area.....when users select a Country it hides and shows different towns.......then when a town is selected different areas show as PDF links.

    Ive now been asked to add search functionality to the whole thing...so I need to build a search form that will search for either a 4 letter identifier <icao>egff</icao> or the area name either in whole or part of such as <area>heathrow</area> then display the relevant pdfs associated within that tag?

    Is it possible to search the XML like that? is it possible to search part names etc and get the full tag?

    I have this as a live website using PHP and SQL.....so it had a lot more functionality the CD is a lite version for those with no internet access.

    Any help or suggestions extremely welcome!

    cheers
    Mike

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    yes it's possible. XPATH would probably be the fastest way to do this. I know for strict XML documents, XPATH is supported in all major browsers, as well as PHP.

    something like:

    Code:
    //icao[contains( . , "eg")]
    or
    Code:
    //area[contains( . , "hea")]
    should work if my xpath memory is correct.

    check out w3schools for examples on how to use xpath.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks!

    Ive had a look at the W3 site and I cant work out exatly how that code will fit in / work?

    can you explain a bit more please?

    thanks
    Mike

  • #4
    New to the CF scene
    Join Date
    Apr 2009
    Location
    Atlanta, Georgia, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    XPath explained!

    XPath, the XML Path Language, is a query language for selecting nodes from an XML document. In addition, XPath may be used to compute values (e.g., strings, numbers, or Boolean values) from the content of an XML document. XPath was defined by the World Wide Web Consortium (W3C).

    There are currently two versions in use.

    XPath 1.0 became a Recommendation on 16 November 1999 and is widely implemented and used, either on its own (called via an API from languages such as Java, C# or JavaScript), or embedded in languages such as XSLT or XForms.

    The current version of the language is XPath 2.0, which became a Recommendation on 23 January 2007. A number of implementations exist but are not as widely used as XPath 1.0. The XPath 2.0 language specification is much larger than XPath 1.0 and changes some of the fundamental concepts of the language such as the type system; the language specification is described in a separate article.

    The most notable change is that XPath 2.0 has a much richer type system;[2] Every value is now a sequence (a single atomic value or node is regarded as a sequence of length one). XPath 1.0 node-sets are replaced by node sequences, which may be in any order.

    To support richer type sets, XPath 2.0 offers a greatly expanded set of functions and operators.

    XPath 2.0 is in fact a subset of XQuery 1.0. It offers a for expression which is cut-down version of the "FLWOR" expressions in XQuery. It is possible to describe the language by listing the parts of XQuery that it leaves out: the main examples are the query prolog, element and attribute constructors, the remainder of the "FLWOR" syntax, and the typeswitch expression.

    See also:

    * XPath 1.0
    * XPath 2.0
    Last edited by WA; 04-17-2009 at 06:21 AM.

  • #5
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks all for the help.....im getting there now


    Mike


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •