|
-
May 11th, 2004, 11:56 AM
#1
Thread Starter
Lively Member
New to XML, need help with structure.
I'm trying to create the XML equivalent of a ListDictionary or Hashtable. So what would that look like? I'm getting confused by elements, nodes, childnodes, I mean XML is designed for nesting data but I really need to keep it simple for my purposes.
I just need to have TWO fields, name and URL, kind of like KEY and VALUE in a hashtable.
That way a client reading the file can get a list all the available web services I specify in the file, get the name of the affiliate running the service and the web service URL associated with the affiliate.
Any help would be appreciated. I've been getting shafted around here for a couple of days now, where are all the regulars at?
KT
-
May 11th, 2004, 12:13 PM
#2
Code:
<myItem>
<name>Hey</name>
<url>http://www.gg.com</url>
</myItem>
-
May 11th, 2004, 12:46 PM
#3
Or more accuratly:
First thing you'll proly want in the project is the MSXML parser, wich comes in version 2-4, depending on the capabilities you want. Then it's a matter of creating a DOMDocument, creating a node, setting it as the DocumentElement of your DOMDocument object, then appending nodes to the DocumentElement.
TG
-
May 11th, 2004, 12:53 PM
#4
Also to explain the xml terminology you might be confused by... Elements in the example above are <myList>, <myItem>, <name>, <url>
An Attribute is the id = "1"
Childnodes. A node nested in another called the parent...so myItem is a child of myList. name and url are children of myItem.
Get it?
-
May 11th, 2004, 01:12 PM
#5
Thread Starter
Lively Member
Gentlmen,
Thanks a lot for all your help! I decided to go a step further and allow each affiliate to have more than one URL for redundancy, so my XML document looks as follows:
Now, using the C1 components I was able to generate a dynamic command list based on this XML document at runtime.
VB Code:
Private Sub LoadNetworkList()
networkList.Clear()
xmd.Load("http://urltoxmldocument/discovery.xml")
Dim node As XmlNode = xmd.DocumentElement
Dim count As Integer = 0
For Each node In xmd.DocumentElement.ChildNodes
Select Case node.Name
Case "Services"
Me.mnuNetwork.CommandLinks.Add(New C1CommandLink)
Me.mnuNetwork.CommandLinks(count).Command = New C1Command
Me.mnuNetwork.CommandLinks(count).Command.Text = node.Attributes(0).Value
Me.mnuNetwork.CommandLinks(count).Command.Name = "cmdNetwork" & node.Attributes(0).Value
networkList.Add(node.Attributes(0).Value, node.ChildNodes(0).ChildNodes(0).Value)
count += 1
End Select
Next node
End Sub
But now I have a new problem. Realizing I can't store values for the commands, I also added the xml data to a listdictionary where i can look it up by key. But how do I handle the click events for these runtime command buttons? like for example, m4DS0ft was an affiliate name in the xml document. so one of the commands generated at runtime was cmdNetworkm4DS0ft. How can I handle an event for a command that does not exist? Remember, I don't know that it's m4ds0ft, it could be any name. I basically want to change the web service URL when one of these is clicked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|