TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Joel Clark
NA
1
0
Very Newb Question. XML & VB 2008
May 26 2009 5:35 AM
Please excuse my 'newbness' before answering this as I have been toiling on google for hours trying to find at least a sample of code that would point me in the right direction.
I have searched the forums here too with not much luck.
I have found that what I am trying to do, although not unique, is not common. I have an external program that i call via shell that exports certain reg keys out into an xml. EG;
-
<
item
>
<
location
>
HKLM\System\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\StartupPrograms
</
location
>
<
itemname
>
rdpclip
</
itemname
>
<
launchstring
>
rdpclip
</
launchstring
>
<
description
>
RDP Clip Monitor
</
description
>
<
company
>
Microsoft Corporation
</
company
>
<
version
>
5.1.2600.5512
</
version
>
<
imagepath
>
c:\windows\system32\rdpclip.exe
</
imagepath
>
<
md5hash
>
dccf6ed915bc05c244801b550ad12b17
</
md5hash
>
<
sha1hash
>
8c63f11d7035840bcf4197b5e6b135bb569d1293
</
sha1hash
>
<
sha256hash
>
c3a7f5fac1672ae403a169c7e80ab19e371283d1923be6e66ab1152a35f3cacf
</
sha256hash
>
</
item
>
I want to be able to define each 'item' instance, and the information that follows as a variable or an array. I also need to compare two xml files, a source and a comparison, and remove the identical entries from the source (but only checking the lines 'location' 'launchstring' 'description' and 'imagepath'.
This is the main problem, I can define a particular reference eg; launchstring - but I cannot define the whole node.
My second problem is the comparison. For this to function well, it must cross check against the comparison file and remove those entries out of the source. Then I have to display the source in a table in the interface (But thats the easy part :-) )
In a nutshell, you click a button, it exports certain reg entries from the machine its being run on (the source), compares that against a database of gathered entries(the comparison), deletes the entries that are the same from the source and then displays a list of entries that are not the same. Then i will add functionality for the user to select which entries should be kept and then those entries will be written to the comparison and any left over will be deleted.
Thats it in a nutshell.
Im not asking for a whole code, or even a sample, though that would help, rather just a leg up and a point in the right direction.
Thanks in advance
Joel
UPDATED
Got at least some code done that can identify specific nodes as var.
Dim Xdoc As XmlDocument = New XmlDocument
Sub xml()
Xdoc.Load("sample.xml")
Dim item As XmlNodeList = Xdoc.GetElementsByTagName("item")
So now I have each 'item tree' specified. Now I need to program the code to crawl between <item> and </item> and produce variables for the items contained within this area. I already have a;
For Each item As XmlNodeList Do
With following code to specify the subnodes(as called by me :-) ) but it crawls the whole document instead of the range I want??!!
Again, a finger pointed in the right direction would be very helpfull :-)
UPDATED
On recollection , I decided to create a function to do this;
Function xmlLoadDoc(ByVal node As String, ByVal nodeIndex As Integer) As String
Dim Xdoc As XmlDocument = New XmlDocument
Dim item As XmlNodeList
Xdoc.Load(My.Application.Info.DirectoryPath & "\sample.xml")
item = Xdoc.GetElementsByTagName(node)
xmlLoadDoc = (item(nodeIndex).InnerText)
I then managed to get the result to print.
Dim nodeLocation, nodeDesc, nodeImagePath As String
Dim i As Integer
For i = 1 To 1
nodeLocation = xmlLoadDoc("location", i)
nodeDesc = xmlLoadDoc("description", i)
nodeImagePath = xmlLoadDoc("item", i)
Debug.Print(nodeDesc & " is at " & nodeLocation & " and the filename is " & nodeImagePath & " this is the no " & i & "record.")
Next
So I guess im on the right path now. Just thought I would post this up for any one else curious about how to do this. Also for reference, I will compare it against a access database instead of a seperate xml document, simply for the purpose of streamlining the memory allocation.
Reply
Answers (
0
)
Have a VB.Net program monitor another program, and when it closes, reopen it
Using Events in VB.net 2003