Fastest way to access data from a file.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ignacio X. Domínguez

    Fastest way to access data from a file.

    Hi. I'm developing a desktop application that needs to store some data in a
    local file. Let's say for example that I want to have an address book with
    names and phone numbers in a file. I would like to be able to retrieve the
    name by searching for a given phone number the fastest I can.

    I have considered the posibility of using XmlTextReader with something like:

    <list>
    <item number="1234567 ">
    <name>John Doe</name>
    </item>
    <item number="9876*">
    <name>Jane Doe</name>
    </item>
    </list>

    or a simple text file with entries separated by special characters:

    1234567~John Doe%9876*~Jane Doe%

    and then use Split("%".ToCha rArray()) to get an array of items, and then
    Split("~".ToCha rArray()) on every item to get name and number.

    I this database will have around 200 entries (name and number in this
    example), so I would like to know which one do you think will perform faster
    and better on most configurations.

    Thank you in advance.

    Ignacio X. Domínguez


  • Dennis Myrén

    #2
    Re: Fastest way to access data from a file.

    I would recommend an XML approach.
    If the data file is not estimated to be gigantic, I would
    use a DOM approach (XmlDocument).
    Than you can perform XPath evaluations, which are fast if they are used
    efficiently,
    to find specific records.
    And the data file also makes great sense when viewing in a text editor,
    which may be good for debugging/monitoring the data easily.

    --
    Regards,
    Dennis JD Myrén
    Oslo Kodebureau
    "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
    news:%23wfstEhm EHA.644@tk2msft ngp13.phx.gbl.. .[color=blue]
    > Hi. I'm developing a desktop application that needs to store some data in[/color]
    a[color=blue]
    > local file. Let's say for example that I want to have an address book with
    > names and phone numbers in a file. I would like to be able to retrieve the
    > name by searching for a given phone number the fastest I can.
    >
    > I have considered the posibility of using XmlTextReader with something[/color]
    like:[color=blue]
    >
    > <list>
    > <item number="1234567 ">
    > <name>John Doe</name>
    > </item>
    > <item number="9876*">
    > <name>Jane Doe</name>
    > </item>
    > </list>
    >
    > or a simple text file with entries separated by special characters:
    >
    > 1234567~John Doe%9876*~Jane Doe%
    >
    > and then use Split("%".ToCha rArray()) to get an array of items, and then
    > Split("~".ToCha rArray()) on every item to get name and number.
    >
    > I this database will have around 200 entries (name and number in this
    > example), so I would like to know which one do you think will perform[/color]
    faster[color=blue]
    > and better on most configurations.
    >
    > Thank you in advance.
    >
    > Ignacio X. Domínguez
    >
    >[/color]


    Comment

    • Ignacio Machin \( .NET/ C#  MVP \)

      #3
      Re: Fastest way to access data from a file.

      Hi tocayo :)

      The fastest way is to having it in memory, you could create a struct with
      two members ( name, number) and have an ArrayList of them.. you read them at
      the beggining and after that all is from memory.

      if for some reason you cannot have them in memory the best way would be
      keeping a text file, not a XML, in the text file you keep one record per
      line, and divide the fields using a special char. For further performance
      you should put the field you will search for first and make it a fixed
      length. in this way you can use String.SubStrin g instead of String.Split

      Ayway , the best way is to keep them all in memory. even so I think that the
      XML is not very good idea here.

      Cheers,

      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation



      "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
      news:%23wfstEhm EHA.644@tk2msft ngp13.phx.gbl.. .[color=blue]
      > Hi. I'm developing a desktop application that needs to store some data in[/color]
      a[color=blue]
      > local file. Let's say for example that I want to have an address book with
      > names and phone numbers in a file. I would like to be able to retrieve the
      > name by searching for a given phone number the fastest I can.
      >
      > I have considered the posibility of using XmlTextReader with something[/color]
      like:[color=blue]
      >
      > <list>
      > <item number="1234567 ">
      > <name>John Doe</name>
      > </item>
      > <item number="9876*">
      > <name>Jane Doe</name>
      > </item>
      > </list>
      >
      > or a simple text file with entries separated by special characters:
      >
      > 1234567~John Doe%9876*~Jane Doe%
      >
      > and then use Split("%".ToCha rArray()) to get an array of items, and then
      > Split("~".ToCha rArray()) on every item to get name and number.
      >
      > I this database will have around 200 entries (name and number in this
      > example), so I would like to know which one do you think will perform[/color]
      faster[color=blue]
      > and better on most configurations.
      >
      > Thank you in advance.
      >
      > Ignacio X. Domínguez
      >
      >[/color]


      Comment

      • Ignacio X. Domínguez

        #4
        Re: Fastest way to access data from a file.

        Hi Dennis,
        [color=blue]
        > If the data file is not estimated to be gigantic, I would
        > use a DOM approach (XmlDocument).[/color]

        I would have around 200 entries in average, in some cases maybe twice that
        number. Do you think using XmlDocument in this case is better than using
        XmlTextReader? or viceversa? Does these load the entire XML file into
        memory?
        [color=blue]
        > Than you can perform XPath evaluations, which are fast if they are used
        > efficiently,[/color]

        What is the most efficient way of using it?


        Thanks in advance.



        "Dennis Myrén" <dennis@oslokb. no> wrote in message
        news:O7x1d.9404 $g%5.105698@new s2.e.nsc.no...[color=blue]
        >I would recommend an XML approach.
        > If the data file is not estimated to be gigantic, I would
        > use a DOM approach (XmlDocument).
        > Than you can perform XPath evaluations, which are fast if they are used
        > efficiently,
        > to find specific records.
        > And the data file also makes great sense when viewing in a text editor,
        > which may be good for debugging/monitoring the data easily.
        >
        > --
        > Regards,
        > Dennis JD Myrén
        > Oslo Kodebureau
        > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
        > news:%23wfstEhm EHA.644@tk2msft ngp13.phx.gbl.. .[color=green]
        >> Hi. I'm developing a desktop application that needs to store some data in[/color]
        > a[color=green]
        >> local file. Let's say for example that I want to have an address book
        >> with
        >> names and phone numbers in a file. I would like to be able to retrieve
        >> the
        >> name by searching for a given phone number the fastest I can.
        >>
        >> I have considered the posibility of using XmlTextReader with something[/color]
        > like:[color=green]
        >>
        >> <list>
        >> <item number="1234567 ">
        >> <name>John Doe</name>
        >> </item>
        >> <item number="9876*">
        >> <name>Jane Doe</name>
        >> </item>
        >> </list>
        >>
        >> or a simple text file with entries separated by special characters:
        >>
        >> 1234567~John Doe%9876*~Jane Doe%
        >>
        >> and then use Split("%".ToCha rArray()) to get an array of items, and then
        >> Split("~".ToCha rArray()) on every item to get name and number.
        >>
        >> I this database will have around 200 entries (name and number in this
        >> example), so I would like to know which one do you think will perform[/color]
        > faster[color=green]
        >> and better on most configurations.
        >>
        >> Thank you in advance.
        >>
        >> Ignacio X. Domínguez
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Ignacio Machin \( .NET/ C#  MVP \)

          #5
          Re: Fastest way to access data from a file.

          Hi,

          That should make a small file, so I will concentrate myself instead on
          which is the most convenient method to make searches/insertions, etc in the
          code.

          In any way you should read all that data in memory.

          cheers,


          --
          Ignacio Machin,
          ignacio.machin AT dot.state.fl.us
          Florida Department Of Transportation



          "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
          news:%23k$%23p3 lmEHA.2372@TK2M SFTNGP10.phx.gb l...[color=blue]
          > Hi Dennis,
          >[color=green]
          > > If the data file is not estimated to be gigantic, I would
          > > use a DOM approach (XmlDocument).[/color]
          >
          > I would have around 200 entries in average, in some cases maybe twice that
          > number. Do you think using XmlDocument in this case is better than using
          > XmlTextReader? or viceversa? Does these load the entire XML file into
          > memory?
          >[color=green]
          > > Than you can perform XPath evaluations, which are fast if they are used
          > > efficiently,[/color]
          >
          > What is the most efficient way of using it?
          >
          >
          > Thanks in advance.
          >
          >
          >
          > "Dennis Myrén" <dennis@oslokb. no> wrote in message
          > news:O7x1d.9404 $g%5.105698@new s2.e.nsc.no...[color=green]
          > >I would recommend an XML approach.
          > > If the data file is not estimated to be gigantic, I would
          > > use a DOM approach (XmlDocument).
          > > Than you can perform XPath evaluations, which are fast if they are used
          > > efficiently,
          > > to find specific records.
          > > And the data file also makes great sense when viewing in a text editor,
          > > which may be good for debugging/monitoring the data easily.
          > >
          > > --
          > > Regards,
          > > Dennis JD Myrén
          > > Oslo Kodebureau
          > > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
          > > news:%23wfstEhm EHA.644@tk2msft ngp13.phx.gbl.. .[color=darkred]
          > >> Hi. I'm developing a desktop application that needs to store some data[/color][/color][/color]
          in[color=blue][color=green]
          > > a[color=darkred]
          > >> local file. Let's say for example that I want to have an address book
          > >> with
          > >> names and phone numbers in a file. I would like to be able to retrieve
          > >> the
          > >> name by searching for a given phone number the fastest I can.
          > >>
          > >> I have considered the posibility of using XmlTextReader with something[/color]
          > > like:[color=darkred]
          > >>
          > >> <list>
          > >> <item number="1234567 ">
          > >> <name>John Doe</name>
          > >> </item>
          > >> <item number="9876*">
          > >> <name>Jane Doe</name>
          > >> </item>
          > >> </list>
          > >>
          > >> or a simple text file with entries separated by special characters:
          > >>
          > >> 1234567~John Doe%9876*~Jane Doe%
          > >>
          > >> and then use Split("%".ToCha rArray()) to get an array of items, and[/color][/color][/color]
          then[color=blue][color=green][color=darkred]
          > >> Split("~".ToCha rArray()) on every item to get name and number.
          > >>
          > >> I this database will have around 200 entries (name and number in this
          > >> example), so I would like to know which one do you think will perform[/color]
          > > faster[color=darkred]
          > >> and better on most configurations.
          > >>
          > >> Thank you in advance.
          > >>
          > >> Ignacio X. Domínguez
          > >>
          > >>[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • Dennis Myrén

            #6
            Re: Fastest way to access data from a file.

            >I would have around 200 entries in average
            200 entries is just about no trouble for the DOM to parse very fast.
            Actually, you could have a lot more than that using DOM as well.
            [color=blue]
            >Does these load the entire XML file into memory?[/color]
            The DOM(XmlDocument ) implementation loads the data into memory,
            whereas the XmlReader(XmlTe xtReader) does not.
            However I do not think that is a problem here.
            [color=blue]
            >What is the most efficient way of using it?[/color]
            Basically just try to avoid the wildcard(*) in XPath evaluations.


            This is my recommendation, assuming the XML look like this:
            <list>
            <item number="1234567 ">
            <name>John Doe</name>
            </item>
            <item number="9876543 ">
            <name>Jane Doe</name>
            </item>
            </list>


            <snippet>
            string filename = "C:\phonenumber s.xml", phonenumber = "1234567";
            XmlDocument doc = new XmlDocument();
            doc.Load(filena me);
            // Select the node.
            XmlNode resultNode = doc.DocumentEle ment.SelectSing leNode
            (string.Format( "item[@number='{0}']", phonenumber));
            // Now we have all information about the item in the resultNode
            instance.
            if (null != resultNode)
            Console.WriteLi ne("Phone number {0} belongs to {1}!"
            , phonenumber, resultNode.Sele ctSingleNode("n ame").InnerText );
            else
            Console.WriteLi ne("Could not find phone number number {0}.", ssn);
            </snippet>



            --
            Regards,
            Dennis JD Myrén
            Oslo Kodebureau
            "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
            news:%23k$%23p3 lmEHA.2372@TK2M SFTNGP10.phx.gb l...[color=blue]
            > Hi Dennis,
            >[color=green]
            > > If the data file is not estimated to be gigantic, I would
            > > use a DOM approach (XmlDocument).[/color]
            >
            > I would have around 200 entries in average, in some cases maybe twice that
            > number. Do you think using XmlDocument in this case is better than using
            > XmlTextReader? or viceversa? Does these load the entire XML file into
            > memory?
            >[color=green]
            > > Than you can perform XPath evaluations, which are fast if they are used
            > > efficiently,[/color]
            >
            > What is the most efficient way of using it?
            >
            >
            > Thanks in advance.
            >
            >
            >
            > "Dennis Myrén" <dennis@oslokb. no> wrote in message
            > news:O7x1d.9404 $g%5.105698@new s2.e.nsc.no...[color=green]
            > >I would recommend an XML approach.
            > > If the data file is not estimated to be gigantic, I would
            > > use a DOM approach (XmlDocument).
            > > Than you can perform XPath evaluations, which are fast if they are used
            > > efficiently,
            > > to find specific records.
            > > And the data file also makes great sense when viewing in a text editor,
            > > which may be good for debugging/monitoring the data easily.
            > >
            > > --
            > > Regards,
            > > Dennis JD Myrén
            > > Oslo Kodebureau
            > > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
            > > news:%23wfstEhm EHA.644@tk2msft ngp13.phx.gbl.. .[color=darkred]
            > >> Hi. I'm developing a desktop application that needs to store some data[/color][/color][/color]
            in[color=blue][color=green]
            > > a[color=darkred]
            > >> local file. Let's say for example that I want to have an address book
            > >> with
            > >> names and phone numbers in a file. I would like to be able to retrieve
            > >> the
            > >> name by searching for a given phone number the fastest I can.
            > >>
            > >> I have considered the posibility of using XmlTextReader with something[/color]
            > > like:[color=darkred]
            > >>
            > >> <list>
            > >> <item number="1234567 ">
            > >> <name>John Doe</name>
            > >> </item>
            > >> <item number="9876*">
            > >> <name>Jane Doe</name>
            > >> </item>
            > >> </list>
            > >>
            > >> or a simple text file with entries separated by special characters:
            > >>
            > >> 1234567~John Doe%9876*~Jane Doe%
            > >>
            > >> and then use Split("%".ToCha rArray()) to get an array of items, and[/color][/color][/color]
            then[color=blue][color=green][color=darkred]
            > >> Split("~".ToCha rArray()) on every item to get name and number.
            > >>
            > >> I this database will have around 200 entries (name and number in this
            > >> example), so I would like to know which one do you think will perform[/color]
            > > faster[color=darkred]
            > >> and better on most configurations.
            > >>
            > >> Thank you in advance.
            > >>
            > >> Ignacio X. Domínguez
            > >>
            > >>[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Ignacio X. Domínguez

              #7
              Re: Fastest way to access data from a file.

              Hi tocayo (hehehe), Why do you think a simple text file is better than a XML
              in this case? The problem I see with the text file is the special separator
              character, because it is going to limit somehow what the strings in each
              entry can contain (can't have that char). Therefore, I need to make sure in
              code that the strings being stored in the text file never contain that
              character. I know I can use any weird character making it unlikely that it
              will be chosen by any user, but there is still a chance.

              What are your thoughts about this?


              "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
              in message news:OzbtBXlmEH A.3608@TK2MSFTN GP09.phx.gbl...[color=blue]
              > Hi tocayo :)
              >
              > The fastest way is to having it in memory, you could create a struct with
              > two members ( name, number) and have an ArrayList of them.. you read them
              > at
              > the beggining and after that all is from memory.
              >
              > if for some reason you cannot have them in memory the best way would be
              > keeping a text file, not a XML, in the text file you keep one record per
              > line, and divide the fields using a special char. For further performance
              > you should put the field you will search for first and make it a fixed
              > length. in this way you can use String.SubStrin g instead of String.Split
              >
              > Ayway , the best way is to keep them all in memory. even so I think that
              > the
              > XML is not very good idea here.
              >
              > Cheers,
              >
              > --
              > Ignacio Machin,
              > ignacio.machin AT dot.state.fl.us
              > Florida Department Of Transportation
              >
              >
              >
              > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
              > news:%23wfstEhm EHA.644@tk2msft ngp13.phx.gbl.. .[color=green]
              >> Hi. I'm developing a desktop application that needs to store some data in[/color]
              > a[color=green]
              >> local file. Let's say for example that I want to have an address book
              >> with
              >> names and phone numbers in a file. I would like to be able to retrieve
              >> the
              >> name by searching for a given phone number the fastest I can.
              >>
              >> I have considered the posibility of using XmlTextReader with something[/color]
              > like:[color=green]
              >>
              >> <list>
              >> <item number="1234567 ">
              >> <name>John Doe</name>
              >> </item>
              >> <item number="9876*">
              >> <name>Jane Doe</name>
              >> </item>
              >> </list>
              >>
              >> or a simple text file with entries separated by special characters:
              >>
              >> 1234567~John Doe%9876*~Jane Doe%
              >>
              >> and then use Split("%".ToCha rArray()) to get an array of items, and then
              >> Split("~".ToCha rArray()) on every item to get name and number.
              >>
              >> I this database will have around 200 entries (name and number in this
              >> example), so I would like to know which one do you think will perform[/color]
              > faster[color=green]
              >> and better on most configurations.
              >>
              >> Thank you in advance.
              >>
              >> Ignacio X. Domínguez
              >>
              >>[/color]
              >
              >[/color]


              Comment

              • Ignacio X. Domínguez

                #8
                Re: Fastest way to access data from a file.

                I was thinking in something like this:

                <phonebook>
                <item number="1234567 ">John Doe</item>
                <item number="7654321 ">Jane Doe</item>
                </phonebook>

                I tried the following code and worked, but not sure if it is the most
                efficient way:

                GetNameFromNumb er(string number)
                {
                System.Xml.XmlT extReader XMLReader = new
                System.Xml.XmlT extReader("Phon eBook.xml");
                XMLReader.MoveT oContent();
                while(XMLReader .Read()
                {
                XMLReader.MoveT oContent();
                string thisnum = XMLReader.GetAt tribute("number ");
                if(thisnum != null && thisnum == number)
                {
                return XMLReader.ReadS tring();
                }
                }
                return null;
                }

                What do you think?

                "Dennis Myrén" <dennis@oslokb. no> wrote in message
                news:2DC1d.9451 $g%5.107298@new s2.e.nsc.no...[color=blue][color=green]
                > >I would have around 200 entries in average[/color]
                > 200 entries is just about no trouble for the DOM to parse very fast.
                > Actually, you could have a lot more than that using DOM as well.
                >[color=green]
                >>Does these load the entire XML file into memory?[/color]
                > The DOM(XmlDocument ) implementation loads the data into memory,
                > whereas the XmlReader(XmlTe xtReader) does not.
                > However I do not think that is a problem here.
                >[color=green]
                >>What is the most efficient way of using it?[/color]
                > Basically just try to avoid the wildcard(*) in XPath evaluations.
                >
                >
                > This is my recommendation, assuming the XML look like this:
                > <list>
                > <item number="1234567 ">
                > <name>John Doe</name>
                > </item>
                > <item number="9876543 ">
                > <name>Jane Doe</name>
                > </item>
                > </list>
                >
                >
                > <snippet>
                > string filename = "C:\phonenumber s.xml", phonenumber = "1234567";
                > XmlDocument doc = new XmlDocument();
                > doc.Load(filena me);
                > // Select the node.
                > XmlNode resultNode = doc.DocumentEle ment.SelectSing leNode
                > (string.Format( "item[@number='{0}']", phonenumber));
                > // Now we have all information about the item in the resultNode
                > instance.
                > if (null != resultNode)
                > Console.WriteLi ne("Phone number {0} belongs to {1}!"
                > , phonenumber, resultNode.Sele ctSingleNode("n ame").InnerText );
                > else
                > Console.WriteLi ne("Could not find phone number number {0}.", ssn);
                > </snippet>
                >
                >
                >
                > --
                > Regards,
                > Dennis JD Myrén
                > Oslo Kodebureau
                > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                > news:%23k$%23p3 lmEHA.2372@TK2M SFTNGP10.phx.gb l...[color=green]
                >> Hi Dennis,
                >>[color=darkred]
                >> > If the data file is not estimated to be gigantic, I would
                >> > use a DOM approach (XmlDocument).[/color]
                >>
                >> I would have around 200 entries in average, in some cases maybe twice
                >> that
                >> number. Do you think using XmlDocument in this case is better than using
                >> XmlTextReader? or viceversa? Does these load the entire XML file into
                >> memory?
                >>[color=darkred]
                >> > Than you can perform XPath evaluations, which are fast if they are used
                >> > efficiently,[/color]
                >>
                >> What is the most efficient way of using it?
                >>
                >>
                >> Thanks in advance.
                >>
                >>
                >>
                >> "Dennis Myrén" <dennis@oslokb. no> wrote in message
                >> news:O7x1d.9404 $g%5.105698@new s2.e.nsc.no...[color=darkred]
                >> >I would recommend an XML approach.
                >> > If the data file is not estimated to be gigantic, I would
                >> > use a DOM approach (XmlDocument).
                >> > Than you can perform XPath evaluations, which are fast if they are used
                >> > efficiently,
                >> > to find specific records.
                >> > And the data file also makes great sense when viewing in a text editor,
                >> > which may be good for debugging/monitoring the data easily.
                >> >
                >> > --
                >> > Regards,
                >> > Dennis JD Myrén
                >> > Oslo Kodebureau
                >> > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                >> > news:%23wfstEhm EHA.644@tk2msft ngp13.phx.gbl.. .
                >> >> Hi. I'm developing a desktop application that needs to store some data[/color][/color]
                > in[color=green][color=darkred]
                >> > a
                >> >> local file. Let's say for example that I want to have an address book
                >> >> with
                >> >> names and phone numbers in a file. I would like to be able to retrieve
                >> >> the
                >> >> name by searching for a given phone number the fastest I can.
                >> >>
                >> >> I have considered the posibility of using XmlTextReader with something
                >> > like:
                >> >>
                >> >> <list>
                >> >> <item number="1234567 ">
                >> >> <name>John Doe</name>
                >> >> </item>
                >> >> <item number="9876*">
                >> >> <name>Jane Doe</name>
                >> >> </item>
                >> >> </list>
                >> >>
                >> >> or a simple text file with entries separated by special characters:
                >> >>
                >> >> 1234567~John Doe%9876*~Jane Doe%
                >> >>
                >> >> and then use Split("%".ToCha rArray()) to get an array of items, and[/color][/color]
                > then[color=green][color=darkred]
                >> >> Split("~".ToCha rArray()) on every item to get name and number.
                >> >>
                >> >> I this database will have around 200 entries (name and number in this
                >> >> example), so I would like to know which one do you think will perform
                >> > faster
                >> >> and better on most configurations.
                >> >>
                >> >> Thank you in advance.
                >> >>
                >> >> Ignacio X. Domínguez
                >> >>
                >> >>
                >> >
                >> >[/color]
                >>
                >>[/color]
                >
                >[/color]


                Comment

                • Ignacio Machin \( .NET/ C#  MVP \)

                  #9
                  Re: Fastest way to access data from a file.

                  Hi,




                  If you use a text file, y


                  "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                  news:eK%23i2Zmm EHA.1356@TK2MSF TNGP09.phx.gbl. ..[color=blue]
                  > Hi tocayo (hehehe), Why do you think a simple text file is better than a[/color]
                  XML[color=blue]
                  > in this case?[/color]

                  It's simpler, and faster than the XML approach. With XML you have to deal
                  with building queries, etc, and searching data is not as easy. you have to
                  create objects for each queries, etc.

                  The problem I see with the text file is the special separator[color=blue]
                  > character, because it is going to limit somehow what the strings in each
                  > entry can contain (can't have that char).[/color]

                  No at all, if you use a comma you will get this problem , if you use a
                  control char you will not have it, I have a similar approach in a pocketPC
                  app and I use char(20), therefore I dont have the problem of the separator
                  char happening in a field. a simple String.Split and it's done.

                  then you can use something like a hashtable and use the number ( or names)
                  as index for the other value, very easy, efficient and the code is cleaner.


                  Cheers,

                  --
                  Ignacio Machin,
                  ignacio.machin AT dot.state.fl.us
                  Florida Department Of Transportation


                  Comment

                  • Dennis Myrén

                    #10
                    Re: Fastest way to access data from a file.

                    Yes, if you insist on using the XmlReader, that looks good.
                    Just remember that if you use XmlReader, invoke Close() prior to return from
                    the function,
                    otherwise the file channel remains open.

                    If it is likely the function will be called frequently,
                    then maybe you should think of either having a file channel open or load the
                    data
                    at startup maybe into some array of a custom struct, for best performance
                    possible).

                    struct Item
                    {
                    string number, name;
                    }


                    --
                    Regards,
                    Dennis JD Myrén
                    Oslo Kodebureau
                    "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                    news:%237Uqb4mm EHA.3428@TK2MSF TNGP14.phx.gbl. ..[color=blue]
                    > I was thinking in something like this:
                    >
                    > <phonebook>
                    > <item number="1234567 ">John Doe</item>
                    > <item number="7654321 ">Jane Doe</item>
                    > </phonebook>
                    >
                    > I tried the following code and worked, but not sure if it is the most
                    > efficient way:
                    >
                    > GetNameFromNumb er(string number)
                    > {
                    > System.Xml.XmlT extReader XMLReader = new
                    > System.Xml.XmlT extReader("Phon eBook.xml");
                    > XMLReader.MoveT oContent();
                    > while(XMLReader .Read()
                    > {
                    > XMLReader.MoveT oContent();
                    > string thisnum = XMLReader.GetAt tribute("number ");
                    > if(thisnum != null && thisnum == number)
                    > {
                    > return XMLReader.ReadS tring();
                    > }
                    > }
                    > return null;
                    > }
                    >
                    > What do you think?
                    >
                    > "Dennis Myrén" <dennis@oslokb. no> wrote in message
                    > news:2DC1d.9451 $g%5.107298@new s2.e.nsc.no...[color=green][color=darkred]
                    > > >I would have around 200 entries in average[/color]
                    > > 200 entries is just about no trouble for the DOM to parse very fast.
                    > > Actually, you could have a lot more than that using DOM as well.
                    > >[color=darkred]
                    > >>Does these load the entire XML file into memory?[/color]
                    > > The DOM(XmlDocument ) implementation loads the data into memory,
                    > > whereas the XmlReader(XmlTe xtReader) does not.
                    > > However I do not think that is a problem here.
                    > >[color=darkred]
                    > >>What is the most efficient way of using it?[/color]
                    > > Basically just try to avoid the wildcard(*) in XPath evaluations.
                    > >
                    > >
                    > > This is my recommendation, assuming the XML look like this:
                    > > <list>
                    > > <item number="1234567 ">
                    > > <name>John Doe</name>
                    > > </item>
                    > > <item number="9876543 ">
                    > > <name>Jane Doe</name>
                    > > </item>
                    > > </list>
                    > >
                    > >
                    > > <snippet>
                    > > string filename = "C:\phonenumber s.xml", phonenumber = "1234567";
                    > > XmlDocument doc = new XmlDocument();
                    > > doc.Load(filena me);
                    > > // Select the node.
                    > > XmlNode resultNode = doc.DocumentEle ment.SelectSing leNode
                    > > (string.Format( "item[@number='{0}']", phonenumber));
                    > > // Now we have all information about the item in the resultNode
                    > > instance.
                    > > if (null != resultNode)
                    > > Console.WriteLi ne("Phone number {0} belongs to {1}!"
                    > > , phonenumber, resultNode.Sele ctSingleNode("n ame").InnerText );
                    > > else
                    > > Console.WriteLi ne("Could not find phone number number {0}.", ssn);
                    > > </snippet>
                    > >
                    > >
                    > >
                    > > --
                    > > Regards,
                    > > Dennis JD Myrén
                    > > Oslo Kodebureau
                    > > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                    > > news:%23k$%23p3 lmEHA.2372@TK2M SFTNGP10.phx.gb l...[color=darkred]
                    > >> Hi Dennis,
                    > >>
                    > >> > If the data file is not estimated to be gigantic, I would
                    > >> > use a DOM approach (XmlDocument).
                    > >>
                    > >> I would have around 200 entries in average, in some cases maybe twice
                    > >> that
                    > >> number. Do you think using XmlDocument in this case is better than[/color][/color][/color]
                    using[color=blue][color=green][color=darkred]
                    > >> XmlTextReader? or viceversa? Does these load the entire XML file into
                    > >> memory?
                    > >>
                    > >> > Than you can perform XPath evaluations, which are fast if they are[/color][/color][/color]
                    used[color=blue][color=green][color=darkred]
                    > >> > efficiently,
                    > >>
                    > >> What is the most efficient way of using it?
                    > >>
                    > >>
                    > >> Thanks in advance.
                    > >>
                    > >>
                    > >>
                    > >> "Dennis Myrén" <dennis@oslokb. no> wrote in message
                    > >> news:O7x1d.9404 $g%5.105698@new s2.e.nsc.no...
                    > >> >I would recommend an XML approach.
                    > >> > If the data file is not estimated to be gigantic, I would
                    > >> > use a DOM approach (XmlDocument).
                    > >> > Than you can perform XPath evaluations, which are fast if they are[/color][/color][/color]
                    used[color=blue][color=green][color=darkred]
                    > >> > efficiently,
                    > >> > to find specific records.
                    > >> > And the data file also makes great sense when viewing in a text[/color][/color][/color]
                    editor,[color=blue][color=green][color=darkred]
                    > >> > which may be good for debugging/monitoring the data easily.
                    > >> >
                    > >> > --
                    > >> > Regards,
                    > >> > Dennis JD Myrén
                    > >> > Oslo Kodebureau
                    > >> > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                    > >> > news:%23wfstEhm EHA.644@tk2msft ngp13.phx.gbl.. .
                    > >> >> Hi. I'm developing a desktop application that needs to store some[/color][/color][/color]
                    data[color=blue][color=green]
                    > > in[color=darkred]
                    > >> > a
                    > >> >> local file. Let's say for example that I want to have an address[/color][/color][/color]
                    book[color=blue][color=green][color=darkred]
                    > >> >> with
                    > >> >> names and phone numbers in a file. I would like to be able to[/color][/color][/color]
                    retrieve[color=blue][color=green][color=darkred]
                    > >> >> the
                    > >> >> name by searching for a given phone number the fastest I can.
                    > >> >>
                    > >> >> I have considered the posibility of using XmlTextReader with[/color][/color][/color]
                    something[color=blue][color=green][color=darkred]
                    > >> > like:
                    > >> >>
                    > >> >> <list>
                    > >> >> <item number="1234567 ">
                    > >> >> <name>John Doe</name>
                    > >> >> </item>
                    > >> >> <item number="9876*">
                    > >> >> <name>Jane Doe</name>
                    > >> >> </item>
                    > >> >> </list>
                    > >> >>
                    > >> >> or a simple text file with entries separated by special characters:
                    > >> >>
                    > >> >> 1234567~John Doe%9876*~Jane Doe%
                    > >> >>
                    > >> >> and then use Split("%".ToCha rArray()) to get an array of items, and[/color]
                    > > then[color=darkred]
                    > >> >> Split("~".ToCha rArray()) on every item to get name and number.
                    > >> >>
                    > >> >> I this database will have around 200 entries (name and number in[/color][/color][/color]
                    this[color=blue][color=green][color=darkred]
                    > >> >> example), so I would like to know which one do you think will[/color][/color][/color]
                    perform[color=blue][color=green][color=darkred]
                    > >> > faster
                    > >> >> and better on most configurations.
                    > >> >>
                    > >> >> Thank you in advance.
                    > >> >>
                    > >> >> Ignacio X. Domínguez
                    > >> >>
                    > >> >>
                    > >> >
                    > >> >
                    > >>
                    > >>[/color]
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • Ignacio X. Domínguez

                      #11
                      Re: Fastest way to access data from a file.

                      I chose XmlReader because it doesn't load the XML into memory. The function
                      is going to be called VERY frequently but the file can also be updated
                      externally. So if I don't invoke Close() it keeps the file channel open and
                      reuses it again on the next call or it leaves many open channels? Thank you
                      SO much for your help.


                      "Dennis Myrén" <dennis@oslokb. no> wrote in message
                      news:xQR1d.7248 $WW4.106897@new s4.e.nsc.no...[color=blue]
                      > Yes, if you insist on using the XmlReader, that looks good.
                      > Just remember that if you use XmlReader, invoke Close() prior to return
                      > from
                      > the function,
                      > otherwise the file channel remains open.
                      >
                      > If it is likely the function will be called frequently,
                      > then maybe you should think of either having a file channel open or load
                      > the
                      > data
                      > at startup maybe into some array of a custom struct, for best performance
                      > possible).
                      >
                      > struct Item
                      > {
                      > string number, name;
                      > }
                      >
                      >
                      > --
                      > Regards,
                      > Dennis JD Myrén
                      > Oslo Kodebureau
                      > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                      > news:%237Uqb4mm EHA.3428@TK2MSF TNGP14.phx.gbl. ..[color=green]
                      >> I was thinking in something like this:
                      >>
                      >> <phonebook>
                      >> <item number="1234567 ">John Doe</item>
                      >> <item number="7654321 ">Jane Doe</item>
                      >> </phonebook>
                      >>
                      >> I tried the following code and worked, but not sure if it is the most
                      >> efficient way:
                      >>
                      >> GetNameFromNumb er(string number)
                      >> {
                      >> System.Xml.XmlT extReader XMLReader = new
                      >> System.Xml.XmlT extReader("Phon eBook.xml");
                      >> XMLReader.MoveT oContent();
                      >> while(XMLReader .Read()
                      >> {
                      >> XMLReader.MoveT oContent();
                      >> string thisnum = XMLReader.GetAt tribute("number ");
                      >> if(thisnum != null && thisnum == number)
                      >> {
                      >> return XMLReader.ReadS tring();
                      >> }
                      >> }
                      >> return null;
                      >> }
                      >>
                      >> What do you think?
                      >>
                      >> "Dennis Myrén" <dennis@oslokb. no> wrote in message
                      >> news:2DC1d.9451 $g%5.107298@new s2.e.nsc.no...[color=darkred]
                      >> > >I would have around 200 entries in average
                      >> > 200 entries is just about no trouble for the DOM to parse very fast.
                      >> > Actually, you could have a lot more than that using DOM as well.
                      >> >
                      >> >>Does these load the entire XML file into memory?
                      >> > The DOM(XmlDocument ) implementation loads the data into memory,
                      >> > whereas the XmlReader(XmlTe xtReader) does not.
                      >> > However I do not think that is a problem here.
                      >> >
                      >> >>What is the most efficient way of using it?
                      >> > Basically just try to avoid the wildcard(*) in XPath evaluations.
                      >> >
                      >> >
                      >> > This is my recommendation, assuming the XML look like this:
                      >> > <list>
                      >> > <item number="1234567 ">
                      >> > <name>John Doe</name>
                      >> > </item>
                      >> > <item number="9876543 ">
                      >> > <name>Jane Doe</name>
                      >> > </item>
                      >> > </list>
                      >> >
                      >> >
                      >> > <snippet>
                      >> > string filename = "C:\phonenumber s.xml", phonenumber = "1234567";
                      >> > XmlDocument doc = new XmlDocument();
                      >> > doc.Load(filena me);
                      >> > // Select the node.
                      >> > XmlNode resultNode = doc.DocumentEle ment.SelectSing leNode
                      >> > (string.Format( "item[@number='{0}']", phonenumber));
                      >> > // Now we have all information about the item in the resultNode
                      >> > instance.
                      >> > if (null != resultNode)
                      >> > Console.WriteLi ne("Phone number {0} belongs to {1}!"
                      >> > , phonenumber, resultNode.Sele ctSingleNode("n ame").InnerText );
                      >> > else
                      >> > Console.WriteLi ne("Could not find phone number number {0}.", ssn);
                      >> > </snippet>
                      >> >
                      >> >
                      >> >
                      >> > --
                      >> > Regards,
                      >> > Dennis JD Myrén
                      >> > Oslo Kodebureau
                      >> > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                      >> > news:%23k$%23p3 lmEHA.2372@TK2M SFTNGP10.phx.gb l...
                      >> >> Hi Dennis,
                      >> >>
                      >> >> > If the data file is not estimated to be gigantic, I would
                      >> >> > use a DOM approach (XmlDocument).
                      >> >>
                      >> >> I would have around 200 entries in average, in some cases maybe twice
                      >> >> that
                      >> >> number. Do you think using XmlDocument in this case is better than[/color][/color]
                      > using[color=green][color=darkred]
                      >> >> XmlTextReader? or viceversa? Does these load the entire XML file into
                      >> >> memory?
                      >> >>
                      >> >> > Than you can perform XPath evaluations, which are fast if they are[/color][/color]
                      > used[color=green][color=darkred]
                      >> >> > efficiently,
                      >> >>
                      >> >> What is the most efficient way of using it?
                      >> >>
                      >> >>
                      >> >> Thanks in advance.
                      >> >>
                      >> >>
                      >> >>
                      >> >> "Dennis Myrén" <dennis@oslokb. no> wrote in message
                      >> >> news:O7x1d.9404 $g%5.105698@new s2.e.nsc.no...
                      >> >> >I would recommend an XML approach.
                      >> >> > If the data file is not estimated to be gigantic, I would
                      >> >> > use a DOM approach (XmlDocument).
                      >> >> > Than you can perform XPath evaluations, which are fast if they are[/color][/color]
                      > used[color=green][color=darkred]
                      >> >> > efficiently,
                      >> >> > to find specific records.
                      >> >> > And the data file also makes great sense when viewing in a text[/color][/color]
                      > editor,[color=green][color=darkred]
                      >> >> > which may be good for debugging/monitoring the data easily.
                      >> >> >
                      >> >> > --
                      >> >> > Regards,
                      >> >> > Dennis JD Myrén
                      >> >> > Oslo Kodebureau
                      >> >> > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                      >> >> > news:%23wfstEhm EHA.644@tk2msft ngp13.phx.gbl.. .
                      >> >> >> Hi. I'm developing a desktop application that needs to store some[/color][/color]
                      > data[color=green][color=darkred]
                      >> > in
                      >> >> > a
                      >> >> >> local file. Let's say for example that I want to have an address[/color][/color]
                      > book[color=green][color=darkred]
                      >> >> >> with
                      >> >> >> names and phone numbers in a file. I would like to be able to[/color][/color]
                      > retrieve[color=green][color=darkred]
                      >> >> >> the
                      >> >> >> name by searching for a given phone number the fastest I can.
                      >> >> >>
                      >> >> >> I have considered the posibility of using XmlTextReader with[/color][/color]
                      > something[color=green][color=darkred]
                      >> >> > like:
                      >> >> >>
                      >> >> >> <list>
                      >> >> >> <item number="1234567 ">
                      >> >> >> <name>John Doe</name>
                      >> >> >> </item>
                      >> >> >> <item number="9876*">
                      >> >> >> <name>Jane Doe</name>
                      >> >> >> </item>
                      >> >> >> </list>
                      >> >> >>
                      >> >> >> or a simple text file with entries separated by special characters:
                      >> >> >>
                      >> >> >> 1234567~John Doe%9876*~Jane Doe%
                      >> >> >>
                      >> >> >> and then use Split("%".ToCha rArray()) to get an array of items, and
                      >> > then
                      >> >> >> Split("~".ToCha rArray()) on every item to get name and number.
                      >> >> >>
                      >> >> >> I this database will have around 200 entries (name and number in[/color][/color]
                      > this[color=green][color=darkred]
                      >> >> >> example), so I would like to know which one do you think will[/color][/color]
                      > perform[color=green][color=darkred]
                      >> >> > faster
                      >> >> >> and better on most configurations.
                      >> >> >>
                      >> >> >> Thank you in advance.
                      >> >> >>
                      >> >> >> Ignacio X. Domínguez
                      >> >> >>
                      >> >> >>
                      >> >> >
                      >> >> >
                      >> >>
                      >> >>
                      >> >
                      >> >[/color]
                      >>
                      >>[/color]
                      >
                      >[/color]


                      Comment

                      • Dennis Myrén

                        #12
                        Re: Fastest way to access data from a file.

                        >So if I don't invoke Close() it keeps the file channel open and[color=blue]
                        >reuses it again on the next call or it leaves many open channels?[/color]
                        If you are using a local instance, then always call Close() before returning
                        the method.
                        The file channel remains open until hopefully the GC can dispose of it.
                        When you open the file again, a new channel is attempted to be established.
                        Always call Close.
                        [color=blue]
                        >The function is going to be called VERY frequently
                        >but the file can also be updated externally.[/color]
                        Then you have no option but to open the file for each request and close
                        afterwards.
                        I feel somewhat repeatable, but this is another reason for using DOM
                        instead.
                        You could have a global instance, which will allow you to both read and
                        write.
                        The changes will be visible directly to anyone who uses the instance.
                        Only once a session, a file needs to be loaded from disk.
                        And only once a session(assumin g changes have been made) the file needs to
                        be saved back.
                        If multiple instances of your application is lileky to run, you should use a
                        static instance.

                        Well, it is just my thoughts.
                        Of course, your solution will turn out good anyway.


                        --
                        Regards,
                        Dennis JD Myrén
                        Oslo Kodebureau
                        "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                        news:ug5PGY5mEH A.556@tk2msftng p13.phx.gbl...[color=blue]
                        > I chose XmlReader because it doesn't load the XML into memory. The[/color]
                        function[color=blue]
                        > is going to be called VERY frequently but the file can also be updated
                        > externally. So if I don't invoke Close() it keeps the file channel open[/color]
                        and[color=blue]
                        > reuses it again on the next call or it leaves many open channels? Thank[/color]
                        you[color=blue]
                        > SO much for your help.
                        >
                        >
                        > "Dennis Myrén" <dennis@oslokb. no> wrote in message
                        > news:xQR1d.7248 $WW4.106897@new s4.e.nsc.no...[color=green]
                        > > Yes, if you insist on using the XmlReader, that looks good.
                        > > Just remember that if you use XmlReader, invoke Close() prior to return
                        > > from
                        > > the function,
                        > > otherwise the file channel remains open.
                        > >
                        > > If it is likely the function will be called frequently,
                        > > then maybe you should think of either having a file channel open or load
                        > > the
                        > > data
                        > > at startup maybe into some array of a custom struct, for best[/color][/color]
                        performance[color=blue][color=green]
                        > > possible).
                        > >
                        > > struct Item
                        > > {
                        > > string number, name;
                        > > }
                        > >
                        > >
                        > > --
                        > > Regards,
                        > > Dennis JD Myrén
                        > > Oslo Kodebureau
                        > > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                        > > news:%237Uqb4mm EHA.3428@TK2MSF TNGP14.phx.gbl. ..[color=darkred]
                        > >> I was thinking in something like this:
                        > >>
                        > >> <phonebook>
                        > >> <item number="1234567 ">John Doe</item>
                        > >> <item number="7654321 ">Jane Doe</item>
                        > >> </phonebook>
                        > >>
                        > >> I tried the following code and worked, but not sure if it is the most
                        > >> efficient way:
                        > >>
                        > >> GetNameFromNumb er(string number)
                        > >> {
                        > >> System.Xml.XmlT extReader XMLReader = new
                        > >> System.Xml.XmlT extReader("Phon eBook.xml");
                        > >> XMLReader.MoveT oContent();
                        > >> while(XMLReader .Read()
                        > >> {
                        > >> XMLReader.MoveT oContent();
                        > >> string thisnum = XMLReader.GetAt tribute("number ");
                        > >> if(thisnum != null && thisnum == number)
                        > >> {
                        > >> return XMLReader.ReadS tring();
                        > >> }
                        > >> }
                        > >> return null;
                        > >> }
                        > >>
                        > >> What do you think?
                        > >>
                        > >> "Dennis Myrén" <dennis@oslokb. no> wrote in message
                        > >> news:2DC1d.9451 $g%5.107298@new s2.e.nsc.no...
                        > >> > >I would have around 200 entries in average
                        > >> > 200 entries is just about no trouble for the DOM to parse very fast.
                        > >> > Actually, you could have a lot more than that using DOM as well.
                        > >> >
                        > >> >>Does these load the entire XML file into memory?
                        > >> > The DOM(XmlDocument ) implementation loads the data into memory,
                        > >> > whereas the XmlReader(XmlTe xtReader) does not.
                        > >> > However I do not think that is a problem here.
                        > >> >
                        > >> >>What is the most efficient way of using it?
                        > >> > Basically just try to avoid the wildcard(*) in XPath evaluations.
                        > >> >
                        > >> >
                        > >> > This is my recommendation, assuming the XML look like this:
                        > >> > <list>
                        > >> > <item number="1234567 ">
                        > >> > <name>John Doe</name>
                        > >> > </item>
                        > >> > <item number="9876543 ">
                        > >> > <name>Jane Doe</name>
                        > >> > </item>
                        > >> > </list>
                        > >> >
                        > >> >
                        > >> > <snippet>
                        > >> > string filename = "C:\phonenumber s.xml", phonenumber = "1234567";
                        > >> > XmlDocument doc = new XmlDocument();
                        > >> > doc.Load(filena me);
                        > >> > // Select the node.
                        > >> > XmlNode resultNode = doc.DocumentEle ment.SelectSing leNode
                        > >> > (string.Format( "item[@number='{0}']", phonenumber));
                        > >> > // Now we have all information about the item in the resultNode
                        > >> > instance.
                        > >> > if (null != resultNode)
                        > >> > Console.WriteLi ne("Phone number {0} belongs to {1}!"
                        > >> > , phonenumber, resultNode.Sele ctSingleNode("n ame").InnerText );
                        > >> > else
                        > >> > Console.WriteLi ne("Could not find phone number number {0}.",[/color][/color][/color]
                        ssn);[color=blue][color=green][color=darkred]
                        > >> > </snippet>
                        > >> >
                        > >> >
                        > >> >
                        > >> > --
                        > >> > Regards,
                        > >> > Dennis JD Myrén
                        > >> > Oslo Kodebureau
                        > >> > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                        > >> > news:%23k$%23p3 lmEHA.2372@TK2M SFTNGP10.phx.gb l...
                        > >> >> Hi Dennis,
                        > >> >>
                        > >> >> > If the data file is not estimated to be gigantic, I would
                        > >> >> > use a DOM approach (XmlDocument).
                        > >> >>
                        > >> >> I would have around 200 entries in average, in some cases maybe[/color][/color][/color]
                        twice[color=blue][color=green][color=darkred]
                        > >> >> that
                        > >> >> number. Do you think using XmlDocument in this case is better than[/color]
                        > > using[color=darkred]
                        > >> >> XmlTextReader? or viceversa? Does these load the entire XML file[/color][/color][/color]
                        into[color=blue][color=green][color=darkred]
                        > >> >> memory?
                        > >> >>
                        > >> >> > Than you can perform XPath evaluations, which are fast if they are[/color]
                        > > used[color=darkred]
                        > >> >> > efficiently,
                        > >> >>
                        > >> >> What is the most efficient way of using it?
                        > >> >>
                        > >> >>
                        > >> >> Thanks in advance.
                        > >> >>
                        > >> >>
                        > >> >>
                        > >> >> "Dennis Myrén" <dennis@oslokb. no> wrote in message
                        > >> >> news:O7x1d.9404 $g%5.105698@new s2.e.nsc.no...
                        > >> >> >I would recommend an XML approach.
                        > >> >> > If the data file is not estimated to be gigantic, I would
                        > >> >> > use a DOM approach (XmlDocument).
                        > >> >> > Than you can perform XPath evaluations, which are fast if they are[/color]
                        > > used[color=darkred]
                        > >> >> > efficiently,
                        > >> >> > to find specific records.
                        > >> >> > And the data file also makes great sense when viewing in a text[/color]
                        > > editor,[color=darkred]
                        > >> >> > which may be good for debugging/monitoring the data easily.
                        > >> >> >
                        > >> >> > --
                        > >> >> > Regards,
                        > >> >> > Dennis JD Myrén
                        > >> >> > Oslo Kodebureau
                        > >> >> > "Ignacio X. Domínguez" <ignacioxd@cant v.net> wrote in message
                        > >> >> > news:%23wfstEhm EHA.644@tk2msft ngp13.phx.gbl.. .
                        > >> >> >> Hi. I'm developing a desktop application that needs to store some[/color]
                        > > data[color=darkred]
                        > >> > in
                        > >> >> > a
                        > >> >> >> local file. Let's say for example that I want to have an address[/color]
                        > > book[color=darkred]
                        > >> >> >> with
                        > >> >> >> names and phone numbers in a file. I would like to be able to[/color]
                        > > retrieve[color=darkred]
                        > >> >> >> the
                        > >> >> >> name by searching for a given phone number the fastest I can.
                        > >> >> >>
                        > >> >> >> I have considered the posibility of using XmlTextReader with[/color]
                        > > something[color=darkred]
                        > >> >> > like:
                        > >> >> >>
                        > >> >> >> <list>
                        > >> >> >> <item number="1234567 ">
                        > >> >> >> <name>John Doe</name>
                        > >> >> >> </item>
                        > >> >> >> <item number="9876*">
                        > >> >> >> <name>Jane Doe</name>
                        > >> >> >> </item>
                        > >> >> >> </list>
                        > >> >> >>
                        > >> >> >> or a simple text file with entries separated by special[/color][/color][/color]
                        characters:[color=blue][color=green][color=darkred]
                        > >> >> >>
                        > >> >> >> 1234567~John Doe%9876*~Jane Doe%
                        > >> >> >>
                        > >> >> >> and then use Split("%".ToCha rArray()) to get an array of items,[/color][/color][/color]
                        and[color=blue][color=green][color=darkred]
                        > >> > then
                        > >> >> >> Split("~".ToCha rArray()) on every item to get name and number.
                        > >> >> >>
                        > >> >> >> I this database will have around 200 entries (name and number in[/color]
                        > > this[color=darkred]
                        > >> >> >> example), so I would like to know which one do you think will[/color]
                        > > perform[color=darkred]
                        > >> >> > faster
                        > >> >> >> and better on most configurations.
                        > >> >> >>
                        > >> >> >> Thank you in advance.
                        > >> >> >>
                        > >> >> >> Ignacio X. Domínguez
                        > >> >> >>
                        > >> >> >>
                        > >> >> >
                        > >> >> >
                        > >> >>
                        > >> >>
                        > >> >
                        > >> >
                        > >>
                        > >>[/color]
                        > >
                        > >[/color]
                        >
                        >[/color]


                        Comment

                        Working...