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 9 of 9

Thread: searching xml

  1. #1
    drn
    drn is offline
    New to the CF scene
    Join Date
    Dec 2002
    Location
    australia
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    searching xml

    can someone please show me or link to an example where a user can search a xml doc/docs through either xsl, javascript, asp (which ever is best) and press submit where all matching strings are displayed and only those that match

    hope i havent over complicated the question

    thnx drn
    drn

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Check out http://www.mori.com/pubinfo/articles.phtml?cat=all which is a searchable XML doc processed with PHP SAX

    I wouldn't say that's necessarily the best way; but it's a way. As it goes, I'm quite proud of that I can provide source code for interest.
    Last edited by brothercake; 12-22-2002 at 05:59 AM.

  • #3
    drn
    drn is offline
    New to the CF scene
    Join Date
    Dec 2002
    Location
    australia
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    i'm interested
    drn

  • #4
    drn
    drn is offline
    New to the CF scene
    Join Date
    Dec 2002
    Location
    australia
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    and thank you for the links
    drn

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay - with SAX you name three functions to process open tags, close tags, and tag data:

    The three functions I define are called "processOpenTag", "processCloseTag" and "processTagData" - processOpenTag reads attributes from the tags, and decide whether to include the data in an array (which happens at processTagData), based on input criteria from a q str. Once that's done, the array can be sorted etc. and finally output as HTML, using normal php methods.

    This is a categories matrix, which is used to compare the q str values against:

    PHP Code:

    $categories 
    = array(
        
    "p" => array(
            
    "cat" => "Politics",
            
    "sub" => array(
                
    "p" => "Politicans, Parties and Elections",
                
    "c" => "Constitution",
                
    "u" => "Europe",
                
    "l" => "Law and Order",
                
    "e" => "Environment",
                
    "g01" => "General Election 2001",
                
    "g97" => "General Election 1997"
                
    )
            ),
        
    "b" => array(
            
    "cat" => "Business",
            
    "sub" => array(
                
    "i" => "Business Image",
                
    "r" => "Business and Research",
                
    "b" => "Business",
                
    "h" => "Human Resources",
                
    "f" => "Finance",
                
    "p" => "Privatisation",
                
    "c" => "Consumer",
                
    "e" => "E-Business"
                
    )
            ),
        
    "s" => array(
            
    "cat" => "Social",
            
    "sub" => array(
                
    "n" => "National Identity",
                
    "i" => "International",
                
    "h" => "Housing and Regeneration",
                
    "f" => "Families, Education and Employment",
                
    "a" => "NHS and Health",
                
    "c" => "Culture",
                
    "m" => "Media",
                
    "l" => "Leisure",
                
    "s" => "Science"
                
    )
            ),
        
    "m" => array(
            
    "cat" => "Methodology",
            
    "sub" => array(
                
    "r" => "Research Methodology",
                
    "i" => "Impact and Image of Polling",
                
    "p" => "Panels",
                
    "t" => "Technology and Quality"
                
    )
            ),
        
    "c" => array(
            
    "cat" => "Public Consultation",
            
    "sub" => array(
                
    "s" => "Public Service Consultation",
                
    "a" => "Local Government and Research",
                
    "r" => "Local Government Reform",
                
    "p" => "Local Government and Public Perceptions",
                
    "m" => "Local Government Members and Employees"
                
    )
            )
        ); 

    And the rest of the script ... I can't post here because it's too long. I put it at http://www.brothercake.com/Ref/articles.phtml.txt (view source to see the code)

  • #6
    drn
    drn is offline
    New to the CF scene
    Join Date
    Dec 2002
    Location
    australia
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think theres something wrong with the page
    http://www.brothercake.com/Ref/articles.phtml.txt
    drn

  • #7
    drn
    drn is offline
    New to the CF scene
    Join Date
    Dec 2002
    Location
    australia
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sry you say veiw sorce code to see code, my bad
    drn

  • #8
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    can i please see the source code

    the link is bad

  • #9
    New to the CF scene
    Join Date
    May 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PLEASE! Can you please show the source!

    I am so close to fixing a problem... but this is the answer I need. I am trying to go across multiple files etc. Please help!


  •  

    Posting Permissions

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