Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-15-2009, 06:57 PM   PM User | #1
mikenye
New to the CF scene

 
Join Date: Apr 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
mikenye is an unknown quantity at this point
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
mikenye is offline   Reply With Quote
Old 04-15-2009, 11:09 PM   PM User | #2
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,452
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
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 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.8% IE9:11.4% IE10:6.5%
rnd me is offline   Reply With Quote
Old 04-16-2009, 04:35 PM   PM User | #3
mikenye
New to the CF scene

 
Join Date: Apr 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
mikenye is an unknown quantity at this point
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
mikenye is offline   Reply With Quote
Old 04-17-2009, 04:05 AM   PM User | #4
jasonone
New to the CF scene

 
Join Date: Apr 2009
Location: Atlanta, Georgia, USA
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jasonone has a little shameless behaviour in the past
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..
jasonone is offline   Reply With Quote
Old 04-23-2009, 03:36 PM   PM User | #5
mikenye
New to the CF scene

 
Join Date: Apr 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
mikenye is an unknown quantity at this point
Thanks all for the help.....im getting there now


Mike
mikenye is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:00 PM.


Advertisement
Log in to turn off these ads.