[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Read XML File to an array and compare against the values in the array

Asked by LeannTTT in WebApplications, .NET, Microsoft Project Project Management Software

Tags: read XML to array

Good day experts,

I am trying to set up a console application, and make it somehow universal.
What  the purpose of all this is spliting a huge text file in smaller bits , and the separation is based on particular criteria , a part of a string and the position of the string in each row of the original tab delimited file.
The string and position criteria might change so that is why I decided I will put them in an XML file so if anything changes I can simply edit the XML file.
I attach an example of the xml file , it`s very simple.
Let me explain with very clear example.
Let`s say
I have  tab delimited file  looking like this:
**ABCBF  HJIIYT LLOOIHGGGFFDD
NHUYTR   HIIOP   AAAAAAAAJKO
Let`s suppose that in thesecond row the part AAAAAAAA that is in the second row is betwwen 96th and 103th character in the row.We have that bit in the XML file.
The idea is the program to be able to check in every row if the string elements in the XML file are existing in each row of the tab delimited file in the position specified in the XML file for each String(CountStart and CountEndPosition).
Then if a row contains the string from XML file and is in the position specified in the XML file for that particular string , then write the row in file a.txt with the same formating as the original field.
Hence we need to read row 1 and loop throught XML values and see if we find a match in between the XML strings , if we do then write row in file a.txt if not then write the row in file b.txt.Then go to next row until the end.
I was thinking of parsing the XML elements to an array , and then loop through the array while reading the tab delimited file and see if you find  matches.
So far I have only managed to get the Values displaying in the cmd prompt window, which has nothing to do with what I want to do.
I am a newbie and don`t really know much yet.
I am posting my code here and attach the XML file(which I think is correctly structured according to what I want to achieve, as this is my file as well)
Please see the XML file and my code below

Thanks very much in advance


1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
<?xml version="1.0" encoding="utf-8"?>
<Strings>
<String>
		<Name>**ABC</Name>
		<CountStartPosition>5 </CountStartPosition>
		<CountEndPosition>10</CountEndPosition>
	</String>
		<String>
		<Name>AAAAAAAA</Name>
		<CountStartPosition>96</CountStartPosition>
		<CountEndPosition>103</CountEndPosition>
	</String>
	<String>
		<Name>BBBBBBBB</Name>
		<CountStartPosition>96</CountStartPosition>
		<CountEndPosition>103</CountEndPosition>
	</String>
		<String>
		<Name>CCCCCCCC</Name>
		<CountStartPosition>96</CountStartPosition>
		<CountEndPosition>103</CountEndPosition>
	</String>
	</Strings>
 
 
Module Module1
 
 
 
    Sub Main()
        Dim m_xmld As XmlDocument
        Dim m_nodelist As XmlNodeList
        Dim m_node As XmlNode
 
        'Create the XML Document
        m_xmld = New XmlDocument()
 
        'Load the Xml file
        m_xmld.Load("path\XMLFileName.xml")
 
       
 
        'Get the list of name nodes 
        m_nodelist = m_xmld.SelectNodes("/Strings/String")
 
        'Loop through the nodes 
 
        For Each m_node In m_nodelist
 
            'Get the Name Element Value
            Dim NameValue = m_node.ChildNodes.Item(0).InnerText
 
            'Get the Count Start Position Value
            Dim CountStartPositionValue = m_node.ChildNodes.Item(1).InnerText
            'Get the Count End Position Value
            Dim CountEndPositionValue = m_node.ChildNodes.Item(2).InnerText
 
 
 
            'Write Result to the Console
            Console.Write(" Name: " & NameValue & " CountStartPositionValue: " _
            & CountStartPositionValue & " CountEndPositionValue: " _
            & CountEndPositionValue)
            Console.Write(vbCrLf)
        Next
        Console.Read()
 
 
 
    End Sub
 
End Module
[+][-]05/30/09 02:35 AM, ID: 24508409Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: WebApplications, .NET, Microsoft Project Project Management Software
Tags: read XML to array
Sign Up Now!
Solution Provided By: Tiggerito
Participating Experts: 1
Solution Grade: A
 
[+][-]08/28/09 04:33 PM, ID: 25212365Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625