reading multiple text files


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: reading multiple text files

Hybrid View

  1. #1
    simon Guest

    reading multiple text files

    Hello Everybody,

    I am a beginner in XML. All I know right now is to create a simple,
    hard-coded XML file, validate with DTD and display using DOM. Now, I have a
    question for the group.

    I am working on a VB app that will go thru a whole bunch of fixed-length
    text files to look for a specific text string, and I believe XML is the best
    way to handle this task. However, I don't know enough of XML (esp within
    VB) to get started. Can anyone give me some help?

    Thank you very much.



  2. #2
    Russell Jones Guest

    Re: reading multiple text files

    Unless you're planning to search the text files repeatedly for information,
    I don't think you're going to get much benefit from XML based on the
    description you gave here. Also, bear in mind that XML is case-sensitive,
    and performing non-case-sensitive searches is not intuitive (but it's
    possible). However, if you *are* planning to search the files repeatedly,
    post a sample of the file, state the type of search you need to perform and
    someone here will help. Also, you should read Kurt Cagle's XML 10-Minute Pro
    article on transforming flat files to XML (link below).
    http://gethelp.devx.com/techtips/xml...kc060501-1.asp

    Russell Jones
    Sr. Web Development Editor,
    DevX.com


    "simon" <substring0@hotmail.com> wrote in message
    news:3b5f4697@news.devx.com...
    > Hello Everybody,
    >
    > I am a beginner in XML. All I know right now is to create a simple,
    > hard-coded XML file, validate with DTD and display using DOM. Now, I have

    a
    > question for the group.
    >
    > I am working on a VB app that will go thru a whole bunch of fixed-length
    > text files to look for a specific text string, and I believe XML is the

    best
    > way to handle this task. However, I don't know enough of XML (esp within
    > VB) to get started. Can anyone give me some help?
    >
    > Thank you very much.
    >
    >




  3. #3
    simon Guest

    Re: reading multiple text files

    Thank you very much for the response. Yes, the text file search is
    performed on a regular basis throughout the day. The case-sensitivity is
    not an issue because the search string is always numeric.

    Furthermore, this text search is just the tip of an iceberg. We receive
    these fixed-length text files from external sources, and the information
    will be processed across multiple databases and multiple platforms. That is
    the primary reason why I think we should convert the text files into XML. I
    also envision that the users from different locations can run their queries
    and view the results on our intranet. But feel free to correct me if I am
    wrong on this assessment.

    The following is a small sample of the fixed-length text file. The customer
    names are replaced with Xs, and some of the numbers are altered because of
    the NDA issue.
    S0008000013215A51686 E XXXXXXXXXX 1238259241000
    10000N000000YND000N0911
    S0008000013215755572 B XXXXXXXXXX 1235756870000
    10000N000000YYA000N0911
    S0008000013216278236 Z XXXXXXXXXX 1239243277000
    10000N000000YND000N0911

    Any help or suggestion will be very much appreciated.

    simon.


    "Russell Jones" <arj1@northstate.net> wrote in message
    news:3b5fa13c$1@news.devx.com...
    > Unless you're planning to search the text files repeatedly for

    information,
    > I don't think you're going to get much benefit from XML based on the
    > description you gave here. Also, bear in mind that XML is case-sensitive,
    > and performing non-case-sensitive searches is not intuitive (but it's
    > possible). However, if you *are* planning to search the files repeatedly,
    > post a sample of the file, state the type of search you need to perform

    and
    > someone here will help. Also, you should read Kurt Cagle's XML 10-Minute

    Pro
    > article on transforming flat files to XML (link below).
    > http://gethelp.devx.com/techtips/xml...kc060501-1.asp
    >
    > Russell Jones
    > Sr. Web Development Editor,
    > DevX.com
    >
    >
    > "simon" <substring0@hotmail.com> wrote in message
    > news:3b5f4697@news.devx.com...
    > > Hello Everybody,
    > >
    > > I am a beginner in XML. All I know right now is to create a simple,
    > > hard-coded XML file, validate with DTD and display using DOM. Now, I

    have
    > a
    > > question for the group.
    > >
    > > I am working on a VB app that will go thru a whole bunch of fixed-length
    > > text files to look for a specific text string, and I believe XML is the

    > best
    > > way to handle this task. However, I don't know enough of XML (esp

    within
    > > VB) to get started. Can anyone give me some help?
    > >
    > > Thank you very much.
    > >
    > >

    >
    >




  4. #4
    Russell Jones Guest

    Re: reading multiple text files

    Simon:

    What you'll need to do is create the XML document, wrapping the data in xml
    tags. Obviously, the tag names I've used are just for example purposes--you
    should use meaningful tag names:
    <?xml version="1.0"?>
    <customers>
    <customer>
    <field1>S0008000013215A51686</field1>
    <field2>E</field2>
    <name>XXXXXXXXXX</name>
    <id>1238259241000</id>
    <field4>10000N000000YND000N0911</field4>
    </customer>
    <customer>
    <field1>S0008000013215755572</field1>
    <field2>B</field2>
    <name>XXXXXXXXXX</name>
    <id>1235756870000</id>
    <field4>10000N000000YYA000N0911</field4>
    </customer>
    </customers>


    Save the result as an XML file. You should be able to process the text files
    relatively easily with any programming language.

    Here's a small demo. Save the sample XML file in this message as
    c:\customers.xml.
    Create a new VB project and paste this code into the form. If you don't have
    VB, you may still be able to glean something useful from the example.

    Option Explicit

    Private Sub Form_Load()
    Dim xml As DOMDocument
    Dim N As IXMLDOMNode
    Set xml = New DOMDocument
    xml.async = False
    xml.Load "c:\customers.xml"
    Set N = findCustomerByID("1235756870000", xml)
    Call showCustomer(N)
    End Sub

    Function findCustomerByID(id As String, xml As DOMDocument) As IXMLDOMNode
    Dim N As IXMLDOMNode
    Set N = xml.selectSingleNode("customers/customer[id='" & id & "']")
    Set findCustomerByID = N
    End Function
    Sub showCustomer(N As IXMLDOMNode)
    Dim NChild As IXMLDOMNode
    If Not N Is Nothing Then
    If N.hasChildNodes Then
    For Each NChild In N.childNodes
    Debug.Print NChild.nodeName, NChild.Text
    Next
    End If
    End If
    End Sub




    "simon" <substring0@hotmail.com> wrote in message
    news:3b60227e$1@news.devx.com...
    > Thank you very much for the response. Yes, the text file search is
    > performed on a regular basis throughout the day. The case-sensitivity is
    > not an issue because the search string is always numeric.
    >
    > Furthermore, this text search is just the tip of an iceberg. We receive
    > these fixed-length text files from external sources, and the information
    > will be processed across multiple databases and multiple platforms. That

    is
    > the primary reason why I think we should convert the text files into XML.

    I
    > also envision that the users from different locations can run their

    queries
    > and view the results on our intranet. But feel free to correct me if I am
    > wrong on this assessment.
    >
    > The following is a small sample of the fixed-length text file. The

    customer
    > names are replaced with Xs, and some of the numbers are altered because of
    > the NDA issue.
    > S0008000013215A51686 E XXXXXXXXXX 1238259241000
    > 10000N000000YND000N0911
    > S0008000013215755572 B XXXXXXXXXX 1235756870000
    > 10000N000000YYA000N0911
    > S0008000013216278236 Z XXXXXXXXXX 1239243277000
    > 10000N000000YND000N0911
    >
    > Any help or suggestion will be very much appreciated.
    >
    > simon.
    >
    >
    > "Russell Jones" <arj1@northstate.net> wrote in message
    > news:3b5fa13c$1@news.devx.com...
    > > Unless you're planning to search the text files repeatedly for

    > information,
    > > I don't think you're going to get much benefit from XML based on the
    > > description you gave here. Also, bear in mind that XML is

    case-sensitive,
    > > and performing non-case-sensitive searches is not intuitive (but it's
    > > possible). However, if you *are* planning to search the files

    repeatedly,
    > > post a sample of the file, state the type of search you need to perform

    > and
    > > someone here will help. Also, you should read Kurt Cagle's XML 10-Minute

    > Pro
    > > article on transforming flat files to XML (link below).
    > > http://gethelp.devx.com/techtips/xml...kc060501-1.asp
    > >
    > > Russell Jones
    > > Sr. Web Development Editor,
    > > DevX.com
    > >
    > >
    > > "simon" <substring0@hotmail.com> wrote in message
    > > news:3b5f4697@news.devx.com...
    > > > Hello Everybody,
    > > >
    > > > I am a beginner in XML. All I know right now is to create a simple,
    > > > hard-coded XML file, validate with DTD and display using DOM. Now, I

    > have
    > > a
    > > > question for the group.
    > > >
    > > > I am working on a VB app that will go thru a whole bunch of

    fixed-length
    > > > text files to look for a specific text string, and I believe XML is

    the
    > > best
    > > > way to handle this task. However, I don't know enough of XML (esp

    > within
    > > > VB) to get started. Can anyone give me some help?
    > > >
    > > > Thank you very much.
    > > >
    > > >

    > >
    > >

    >
    >




  5. #5
    simon Guest

    Re: reading multiple text files

    Russell,

    Thank you for the example. It will help me trememdously. Now, I have a
    couple questions on that.

    From the XML class I took (I was disappointed because the class was too
    basic), I learned to put values between the user-defined tags (or elements)
    to create the XML document. However, those values will change from text
    file to text file. How can I pass variables to those spaces instead? I
    guess my question is that how can I "reuse" the XML document as a template
    for other text files if the values are already on it? Or am I totally
    misunderstood XML document?

    Secondly, do I need to add any reference in order to dimension a variable as
    DOMDocument? Is it an Add-in that I need to download from Microsoft or
    something? I am using VB6 SP5, on WindowsNT4.0.

    Again, thank you very much for your help.

    simon.


    "Russell Jones" <arj1@northstate.net> wrote in message
    news:3b603b79$1@news.devx.com...
    > Simon:
    >
    > What you'll need to do is create the XML document, wrapping the data in

    xml
    > tags. Obviously, the tag names I've used are just for example

    purposes--you
    > should use meaningful tag names:
    > <?xml version="1.0"?>
    > <customers>
    > <customer>
    > <field1>S0008000013215A51686</field1>
    > <field2>E</field2>
    > <name>XXXXXXXXXX</name>
    > <id>1238259241000</id>
    > <field4>10000N000000YND000N0911</field4>
    > </customer>
    > <customer>
    > <field1>S0008000013215755572</field1>
    > <field2>B</field2>
    > <name>XXXXXXXXXX</name>
    > <id>1235756870000</id>
    > <field4>10000N000000YYA000N0911</field4>
    > </customer>
    > </customers>
    >
    >
    > Save the result as an XML file. You should be able to process the text

    files
    > relatively easily with any programming language.
    >
    > Here's a small demo. Save the sample XML file in this message as
    > c:\customers.xml.
    > Create a new VB project and paste this code into the form. If you don't

    have
    > VB, you may still be able to glean something useful from the example.
    >
    > Option Explicit
    >
    > Private Sub Form_Load()
    > Dim xml As DOMDocument
    > Dim N As IXMLDOMNode
    > Set xml = New DOMDocument
    > xml.async = False
    > xml.Load "c:\customers.xml"
    > Set N = findCustomerByID("1235756870000", xml)
    > Call showCustomer(N)
    > End Sub
    >
    > Function findCustomerByID(id As String, xml As DOMDocument) As IXMLDOMNode
    > Dim N As IXMLDOMNode
    > Set N = xml.selectSingleNode("customers/customer[id='" & id & "']")
    > Set findCustomerByID = N
    > End Function
    > Sub showCustomer(N As IXMLDOMNode)
    > Dim NChild As IXMLDOMNode
    > If Not N Is Nothing Then
    > If N.hasChildNodes Then
    > For Each NChild In N.childNodes
    > Debug.Print NChild.nodeName, NChild.Text
    > Next
    > End If
    > End If
    > End Sub
    >
    >
    >
    >
    > "simon" <substring0@hotmail.com> wrote in message
    > news:3b60227e$1@news.devx.com...
    > > Thank you very much for the response. Yes, the text file search is
    > > performed on a regular basis throughout the day. The case-sensitivity

    is
    > > not an issue because the search string is always numeric.
    > >
    > > Furthermore, this text search is just the tip of an iceberg. We receive
    > > these fixed-length text files from external sources, and the information
    > > will be processed across multiple databases and multiple platforms.

    That
    > is
    > > the primary reason why I think we should convert the text files into

    XML.
    > I
    > > also envision that the users from different locations can run their

    > queries
    > > and view the results on our intranet. But feel free to correct me if I

    am
    > > wrong on this assessment.
    > >
    > > The following is a small sample of the fixed-length text file. The

    > customer
    > > names are replaced with Xs, and some of the numbers are altered because

    of
    > > the NDA issue.
    > > S0008000013215A51686 E XXXXXXXXXX 1238259241000
    > > 10000N000000YND000N0911
    > > S0008000013215755572 B XXXXXXXXXX 1235756870000
    > > 10000N000000YYA000N0911
    > > S0008000013216278236 Z XXXXXXXXXX 1239243277000
    > > 10000N000000YND000N0911
    > >
    > > Any help or suggestion will be very much appreciated.
    > >
    > > simon.
    > >
    > >
    > > "Russell Jones" <arj1@northstate.net> wrote in message
    > > news:3b5fa13c$1@news.devx.com...
    > > > Unless you're planning to search the text files repeatedly for

    > > information,
    > > > I don't think you're going to get much benefit from XML based on the
    > > > description you gave here. Also, bear in mind that XML is

    > case-sensitive,
    > > > and performing non-case-sensitive searches is not intuitive (but it's
    > > > possible). However, if you *are* planning to search the files

    > repeatedly,
    > > > post a sample of the file, state the type of search you need to

    perform
    > > and
    > > > someone here will help. Also, you should read Kurt Cagle's XML

    10-Minute
    > > Pro
    > > > article on transforming flat files to XML (link below).
    > > >

    http://gethelp.devx.com/techtips/xml...kc060501-1.asp
    > > >
    > > > Russell Jones
    > > > Sr. Web Development Editor,
    > > > DevX.com
    > > >
    > > >
    > > > "simon" <substring0@hotmail.com> wrote in message
    > > > news:3b5f4697@news.devx.com...
    > > > > Hello Everybody,
    > > > >
    > > > > I am a beginner in XML. All I know right now is to create a simple,
    > > > > hard-coded XML file, validate with DTD and display using DOM. Now,

    I
    > > have
    > > > a
    > > > > question for the group.
    > > > >
    > > > > I am working on a VB app that will go thru a whole bunch of

    > fixed-length
    > > > > text files to look for a specific text string, and I believe XML is

    > the
    > > > best
    > > > > way to handle this task. However, I don't know enough of XML (esp

    > > within
    > > > > VB) to get started. Can anyone give me some help?
    > > > >
    > > > > Thank you very much.
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >




  6. #6
    Russell Jones Guest

    Re: reading multiple text files

    You should download the release version (v3) of the msxml parser from
    Microsoft (MSDN). There is an as yet unreleased version 4 that is
    significantly faster, expecially for SAX programming. Download the SDK as
    well and read through it. There's an msxsl utility that lets you run
    transforms from the command line--very convenient for quick testing. There
    are multiple examples, and many more in this newsgroups and in the Microsoft
    XML and XSLT newsgroups that will help.


    "simon" <substring0@hotmail.com> wrote in message
    news:3b606862$1@news.devx.com...
    > Russell,
    >
    > Thank you for the example. It will help me trememdously. Now, I have a
    > couple questions on that.
    >
    > From the XML class I took (I was disappointed because the class was too
    > basic), I learned to put values between the user-defined tags (or

    elements)
    > to create the XML document. However, those values will change from text
    > file to text file. How can I pass variables to those spaces instead? I
    > guess my question is that how can I "reuse" the XML document as a template
    > for other text files if the values are already on it? Or am I totally
    > misunderstood XML document?
    >
    > Secondly, do I need to add any reference in order to dimension a variable

    as
    > DOMDocument? Is it an Add-in that I need to download from Microsoft or
    > something? I am using VB6 SP5, on WindowsNT4.0.
    >
    > Again, thank you very much for your help.
    >
    > simon.
    >
    >
    > "Russell Jones" <arj1@northstate.net> wrote in message
    > news:3b603b79$1@news.devx.com...
    > > Simon:
    > >
    > > What you'll need to do is create the XML document, wrapping the data in

    > xml
    > > tags. Obviously, the tag names I've used are just for example

    > purposes--you
    > > should use meaningful tag names:
    > > <?xml version="1.0"?>
    > > <customers>
    > > <customer>
    > > <field1>S0008000013215A51686</field1>
    > > <field2>E</field2>
    > > <name>XXXXXXXXXX</name>
    > > <id>1238259241000</id>
    > > <field4>10000N000000YND000N0911</field4>
    > > </customer>
    > > <customer>
    > > <field1>S0008000013215755572</field1>
    > > <field2>B</field2>
    > > <name>XXXXXXXXXX</name>
    > > <id>1235756870000</id>
    > > <field4>10000N000000YYA000N0911</field4>
    > > </customer>
    > > </customers>
    > >
    > >
    > > Save the result as an XML file. You should be able to process the text

    > files
    > > relatively easily with any programming language.
    > >
    > > Here's a small demo. Save the sample XML file in this message as
    > > c:\customers.xml.
    > > Create a new VB project and paste this code into the form. If you don't

    > have
    > > VB, you may still be able to glean something useful from the example.
    > >
    > > Option Explicit
    > >
    > > Private Sub Form_Load()
    > > Dim xml As DOMDocument
    > > Dim N As IXMLDOMNode
    > > Set xml = New DOMDocument
    > > xml.async = False
    > > xml.Load "c:\customers.xml"
    > > Set N = findCustomerByID("1235756870000", xml)
    > > Call showCustomer(N)
    > > End Sub
    > >
    > > Function findCustomerByID(id As String, xml As DOMDocument) As

    IXMLDOMNode
    > > Dim N As IXMLDOMNode
    > > Set N = xml.selectSingleNode("customers/customer[id='" & id & "']")
    > > Set findCustomerByID = N
    > > End Function
    > > Sub showCustomer(N As IXMLDOMNode)
    > > Dim NChild As IXMLDOMNode
    > > If Not N Is Nothing Then
    > > If N.hasChildNodes Then
    > > For Each NChild In N.childNodes
    > > Debug.Print NChild.nodeName, NChild.Text
    > > Next
    > > End If
    > > End If
    > > End Sub
    > >
    > >
    > >
    > >
    > > "simon" <substring0@hotmail.com> wrote in message
    > > news:3b60227e$1@news.devx.com...
    > > > Thank you very much for the response. Yes, the text file search is
    > > > performed on a regular basis throughout the day. The case-sensitivity

    > is
    > > > not an issue because the search string is always numeric.
    > > >
    > > > Furthermore, this text search is just the tip of an iceberg. We

    receive
    > > > these fixed-length text files from external sources, and the

    information
    > > > will be processed across multiple databases and multiple platforms.

    > That
    > > is
    > > > the primary reason why I think we should convert the text files into

    > XML.
    > > I
    > > > also envision that the users from different locations can run their

    > > queries
    > > > and view the results on our intranet. But feel free to correct me if

    I
    > am
    > > > wrong on this assessment.
    > > >
    > > > The following is a small sample of the fixed-length text file. The

    > > customer
    > > > names are replaced with Xs, and some of the numbers are altered

    because
    > of
    > > > the NDA issue.
    > > > S0008000013215A51686 E XXXXXXXXXX 1238259241000
    > > > 10000N000000YND000N0911
    > > > S0008000013215755572 B XXXXXXXXXX 1235756870000
    > > > 10000N000000YYA000N0911
    > > > S0008000013216278236 Z XXXXXXXXXX 1239243277000
    > > > 10000N000000YND000N0911
    > > >
    > > > Any help or suggestion will be very much appreciated.
    > > >
    > > > simon.
    > > >
    > > >
    > > > "Russell Jones" <arj1@northstate.net> wrote in message
    > > > news:3b5fa13c$1@news.devx.com...
    > > > > Unless you're planning to search the text files repeatedly for
    > > > information,
    > > > > I don't think you're going to get much benefit from XML based on the
    > > > > description you gave here. Also, bear in mind that XML is

    > > case-sensitive,
    > > > > and performing non-case-sensitive searches is not intuitive (but

    it's
    > > > > possible). However, if you *are* planning to search the files

    > > repeatedly,
    > > > > post a sample of the file, state the type of search you need to

    > perform
    > > > and
    > > > > someone here will help. Also, you should read Kurt Cagle's XML

    > 10-Minute
    > > > Pro
    > > > > article on transforming flat files to XML (link below).
    > > > >

    > http://gethelp.devx.com/techtips/xml...kc060501-1.asp
    > > > >
    > > > > Russell Jones
    > > > > Sr. Web Development Editor,
    > > > > DevX.com
    > > > >
    > > > >
    > > > > "simon" <substring0@hotmail.com> wrote in message
    > > > > news:3b5f4697@news.devx.com...
    > > > > > Hello Everybody,
    > > > > >
    > > > > > I am a beginner in XML. All I know right now is to create a

    simple,
    > > > > > hard-coded XML file, validate with DTD and display using DOM.

    Now,
    > I
    > > > have
    > > > > a
    > > > > > question for the group.
    > > > > >
    > > > > > I am working on a VB app that will go thru a whole bunch of

    > > fixed-length
    > > > > > text files to look for a specific text string, and I believe XML

    is
    > > the
    > > > > best
    > > > > > way to handle this task. However, I don't know enough of XML (esp
    > > > within
    > > > > > VB) to get started. Can anyone give me some help?
    > > > > >
    > > > > > Thank you very much.
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >




  7. #7
    simon Guest

    Re: reading multiple text files

    Again, thanks for your help. I guess you want me to read the examples to
    solve my puzzle on passing variables huh =). However, I downloaded the 3.0
    Release and the 3.0 SDK. It seems that they have removed the VB examples,
    contrary to what they said on the web page (typical Microsoft, haha). All I
    got from the SDK are a few C++ header files. Anyway, I guess I just have to
    search around for examples of XML on VB.

    Funny thing, most of the articles/web pages/online discussions I came across
    on XML are related to JavaScript and web page development. But I believe
    XML can also be used on the n-tier enterprise environment also, not just for
    web development. For example, if you have a COM component and you want to
    add new parameter, you have to recompile and fight with the version
    compatibility problem. That is a real pain. But if your parameter is
    simply an XML string, you can add as much as your heart desires without
    recompiling..... which is a huge plus to software development.

    Well, enough of the nagging, ha. If you know any good link with examples
    that are close to what I want to do, please let me know. Again, thank you
    very much for your help and your time.

    simon.


    "Russell Jones" <arj1@northstate.net> wrote in message
    news:3b60d346$1@news.devx.com...
    > You should download the release version (v3) of the msxml parser from
    > Microsoft (MSDN). There is an as yet unreleased version 4 that is
    > significantly faster, expecially for SAX programming. Download the SDK as
    > well and read through it. There's an msxsl utility that lets you run
    > transforms from the command line--very convenient for quick testing. There
    > are multiple examples, and many more in this newsgroups and in the

    Microsoft
    > XML and XSLT newsgroups that will help.
    >
    >
    > "simon" <substring0@hotmail.com> wrote in message
    > news:3b606862$1@news.devx.com...
    > > Russell,
    > >
    > > Thank you for the example. It will help me trememdously. Now, I have a
    > > couple questions on that.
    > >
    > > From the XML class I took (I was disappointed because the class was too
    > > basic), I learned to put values between the user-defined tags (or

    > elements)
    > > to create the XML document. However, those values will change from text
    > > file to text file. How can I pass variables to those spaces instead? I
    > > guess my question is that how can I "reuse" the XML document as a

    template
    > > for other text files if the values are already on it? Or am I totally
    > > misunderstood XML document?
    > >
    > > Secondly, do I need to add any reference in order to dimension a

    variable
    > as
    > > DOMDocument? Is it an Add-in that I need to download from Microsoft or
    > > something? I am using VB6 SP5, on WindowsNT4.0.
    > >
    > > Again, thank you very much for your help.
    > >
    > > simon.
    > >
    > >
    > > "Russell Jones" <arj1@northstate.net> wrote in message
    > > news:3b603b79$1@news.devx.com...
    > > > Simon:
    > > >
    > > > What you'll need to do is create the XML document, wrapping the data

    in
    > > xml
    > > > tags. Obviously, the tag names I've used are just for example

    > > purposes--you
    > > > should use meaningful tag names:
    > > > <?xml version="1.0"?>
    > > > <customers>
    > > > <customer>
    > > > <field1>S0008000013215A51686</field1>
    > > > <field2>E</field2>
    > > > <name>XXXXXXXXXX</name>
    > > > <id>1238259241000</id>
    > > > <field4>10000N000000YND000N0911</field4>
    > > > </customer>
    > > > <customer>
    > > > <field1>S0008000013215755572</field1>
    > > > <field2>B</field2>
    > > > <name>XXXXXXXXXX</name>
    > > > <id>1235756870000</id>
    > > > <field4>10000N000000YYA000N0911</field4>
    > > > </customer>
    > > > </customers>
    > > >
    > > >
    > > > Save the result as an XML file. You should be able to process the text

    > > files
    > > > relatively easily with any programming language.
    > > >
    > > > Here's a small demo. Save the sample XML file in this message as
    > > > c:\customers.xml.
    > > > Create a new VB project and paste this code into the form. If you

    don't
    > > have
    > > > VB, you may still be able to glean something useful from the example.
    > > >
    > > > Option Explicit
    > > >
    > > > Private Sub Form_Load()
    > > > Dim xml As DOMDocument
    > > > Dim N As IXMLDOMNode
    > > > Set xml = New DOMDocument
    > > > xml.async = False
    > > > xml.Load "c:\customers.xml"
    > > > Set N = findCustomerByID("1235756870000", xml)
    > > > Call showCustomer(N)
    > > > End Sub
    > > >
    > > > Function findCustomerByID(id As String, xml As DOMDocument) As

    > IXMLDOMNode
    > > > Dim N As IXMLDOMNode
    > > > Set N = xml.selectSingleNode("customers/customer[id='" & id &

    "']")
    > > > Set findCustomerByID = N
    > > > End Function
    > > > Sub showCustomer(N As IXMLDOMNode)
    > > > Dim NChild As IXMLDOMNode
    > > > If Not N Is Nothing Then
    > > > If N.hasChildNodes Then
    > > > For Each NChild In N.childNodes
    > > > Debug.Print NChild.nodeName, NChild.Text
    > > > Next
    > > > End If
    > > > End If
    > > > End Sub
    > > >
    > > >
    > > >
    > > >
    > > > "simon" <substring0@hotmail.com> wrote in message
    > > > news:3b60227e$1@news.devx.com...
    > > > > Thank you very much for the response. Yes, the text file search is
    > > > > performed on a regular basis throughout the day. The

    case-sensitivity
    > > is
    > > > > not an issue because the search string is always numeric.
    > > > >
    > > > > Furthermore, this text search is just the tip of an iceberg. We

    > receive
    > > > > these fixed-length text files from external sources, and the

    > information
    > > > > will be processed across multiple databases and multiple platforms.

    > > That
    > > > is
    > > > > the primary reason why I think we should convert the text files into

    > > XML.
    > > > I
    > > > > also envision that the users from different locations can run their
    > > > queries
    > > > > and view the results on our intranet. But feel free to correct me

    if
    > I
    > > am
    > > > > wrong on this assessment.
    > > > >
    > > > > The following is a small sample of the fixed-length text file. The
    > > > customer
    > > > > names are replaced with Xs, and some of the numbers are altered

    > because
    > > of
    > > > > the NDA issue.
    > > > > S0008000013215A51686 E XXXXXXXXXX 1238259241000
    > > > > 10000N000000YND000N0911
    > > > > S0008000013215755572 B XXXXXXXXXX 1235756870000
    > > > > 10000N000000YYA000N0911
    > > > > S0008000013216278236 Z XXXXXXXXXX 1239243277000
    > > > > 10000N000000YND000N0911
    > > > >
    > > > > Any help or suggestion will be very much appreciated.
    > > > >
    > > > > simon.
    > > > >
    > > > >
    > > > > "Russell Jones" <arj1@northstate.net> wrote in message
    > > > > news:3b5fa13c$1@news.devx.com...
    > > > > > Unless you're planning to search the text files repeatedly for
    > > > > information,
    > > > > > I don't think you're going to get much benefit from XML based on

    the
    > > > > > description you gave here. Also, bear in mind that XML is
    > > > case-sensitive,
    > > > > > and performing non-case-sensitive searches is not intuitive (but

    > it's
    > > > > > possible). However, if you *are* planning to search the files
    > > > repeatedly,
    > > > > > post a sample of the file, state the type of search you need to

    > > perform
    > > > > and
    > > > > > someone here will help. Also, you should read Kurt Cagle's XML

    > > 10-Minute
    > > > > Pro
    > > > > > article on transforming flat files to XML (link below).
    > > > > >

    > > http://gethelp.devx.com/techtips/xml...kc060501-1.asp
    > > > > >
    > > > > > Russell Jones
    > > > > > Sr. Web Development Editor,
    > > > > > DevX.com
    > > > > >
    > > > > >
    > > > > > "simon" <substring0@hotmail.com> wrote in message
    > > > > > news:3b5f4697@news.devx.com...
    > > > > > > Hello Everybody,
    > > > > > >
    > > > > > > I am a beginner in XML. All I know right now is to create a

    > simple,
    > > > > > > hard-coded XML file, validate with DTD and display using DOM.

    > Now,
    > > I
    > > > > have
    > > > > > a
    > > > > > > question for the group.
    > > > > > >
    > > > > > > I am working on a VB app that will go thru a whole bunch of
    > > > fixed-length
    > > > > > > text files to look for a specific text string, and I believe XML

    > is
    > > > the
    > > > > > best
    > > > > > > way to handle this task. However, I don't know enough of XML

    (esp
    > > > > within
    > > > > > > VB) to get started. Can anyone give me some help?
    > > > > > >
    > > > > > > Thank you very much.
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >




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