How do i search within a xml file?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: How do i search within a xml file?

  1. #1
    Kelvin Teh Guest

    How do i search within a xml file?


    hi,

    i'm new to XML. I have this problem regarding searching within a XML file.
    the
    idea is that my search will be based on the keyword entered
    in
    by the user from a HTML form. the keyword is then used to search all
    the
    question nodes and the choice nodes within a XML file. once the match
    is
    found, i will have to display the results.

    But i don't know how to do so - especially the part of searching xml file.

    Can
    anyone help me in this? Attached is the xml file. Your help is much appreciated.


    ---------------------------
    <?xml version="1.0"?>
    <!--<?xml:stylesheet href="QuizXsl.xsl" type="text/xsl"?>-->
    <Quiz>
    <QuestionNo ID="1">
    <Question>What does multimedia means?</Question>
    <Choice ID="A">multiple media on the web.</Choice>
    <Choice ID="B">an application that contains media such as audio, video,
    graphics, text.</Choice>
    <Choice ID="C">media that is completely animated.</Choice>
    <Choice ID="D">media with rich text format (*.rtf)</Choice>
    <Answer>B</Answer>
    </QuestionNo>

    <QuestionNo ID="2">
    <Question>What elements can't be inserted into a html page?</Question>
    <Choice ID="A">text</Choice>
    <Choice ID="B">picture</Choice>
    <Choice ID="C">sound</Choice>
    <Choice ID="D">paper</Choice>
    <Answer>D</Answer>
    </QuestionNo>
    </Quiz>



  2. #2
    Ayaz Guest

    Re: How do i search within a xml file?


    "Kelvin Teh" <kelvinteh@yahoo.com> wrote:
    >
    >hi,
    >
    >i'm new to XML. I have this problem regarding searching within a XML file.
    >the
    >idea is that my search will be based on the keyword entered
    >in
    >by the user from a HTML form. the keyword is then used to search all
    >the
    >question nodes and the choice nodes within a XML file. once the match
    >is
    >found, i will have to display the results.
    >
    >But i don't know how to do so - especially the part of searching xml file.
    >
    >Can
    >anyone help me in this? Attached is the xml file. Your help is much appreciated.
    >
    >
    >---------------------------
    ><?xml version="1.0"?>
    ><!--<?xml:stylesheet href="QuizXsl.xsl" type="text/xsl"?>-->
    ><Quiz>
    > <QuestionNo ID="1">
    > <Question>What does multimedia means?</Question>
    > <Choice ID="A">multiple media on the web.</Choice>
    > <Choice ID="B">an application that contains media such as audio, video,
    >graphics, text.</Choice>
    > <Choice ID="C">media that is completely animated.</Choice>
    > <Choice ID="D">media with rich text format (*.rtf)</Choice>
    > <Answer>B</Answer>
    > </QuestionNo>
    >
    > <QuestionNo ID="2">
    > <Question>What elements can't be inserted into a html page?</Question>
    > <Choice ID="A">text</Choice>
    > <Choice ID="B">picture</Choice>
    > <Choice ID="C">sound</Choice>
    > <Choice ID="D">paper</Choice>
    > <Answer>D</Answer>
    > </QuestionNo>
    ></Quiz>
    >
    >



  3. #3
    Ayaz Guest

    Re: How do i search within a xml file?



    Hi kelvin,
    You may have heard of the DOM. You can use this API (depending on how large
    your XML file is.. if your files are gigabytes in size, then you will have
    to use the SAX api) It is an API that allows you to walk through your XML
    file or XML text stream to go to a particular element and get the values
    of that element. If you need help on the DOM please check out the following
    documentation at MSDN. I have enclosed the url. Hope this helps.http://msdn.microsoft.com/xml/xmlgui...ssing-the-tree
    or
    http://www.w3schools.com
    http://msdn.microsoft.com/xml/refere...interfaces.asp
    http://www.devguru.com/index.asp?pag...dom_intro.html

    All the above sites are great as they have [lenty of cool examples. Good
    Luck
    Ayaz

  4. #4
    Brian Barker Guest

    Re: How do i search within a xml file?


    The simple answer would be to use XPath to locate nodes of interest. But you
    want to look at the content of the nodes, not just the tags. This is beyond
    the scope of the XML specifications. This would be up to another product,
    or possibly the storage vehicle you use for your XML documents. For example,
    Oracle interMedia will let you index and search the the text between tags
    if you store your documents in Oracle. SoftwareAG makes a native XML database
    called Tamino that does the same thing. These are just examples, there are
    plenty of other tools out there. You have to examine your environment and
    requirements.


    "Kelvin Teh" <kelvinteh@yahoo.com> wrote:
    >
    >hi,
    >
    >i'm new to XML. I have this problem regarding searching within a XML file.
    >the
    >idea is that my search will be based on the keyword entered
    >in
    >by the user from a HTML form. the keyword is then used to search all
    >the
    >question nodes and the choice nodes within a XML file. once the match
    >is
    >found, i will have to display the results.
    >
    >But i don't know how to do so - especially the part of searching xml file.
    >
    >Can
    >anyone help me in this? Attached is the xml file. Your help is much appreciated.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center