Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a stream to read, which is like this:

 

<Import>

<Name>Fred Jones</Name>

<Address>101 Main Street</Address>

</Import>

<Import>

<Name>Fred Smith</Name>

<Address>103 Front Street</Address>

</Import>

 

 

Obviously it is more complicated than that - I just have to read the first import then the next, into multiple datasets.

 

If I don't know for sure that the first Node will be 'Import' (it could be 'Imports', 'Data', 'Feed', 'Contact') how can I tell the thing to take all of the Nodes with the start item of 'whatever' and read them?

Read the Fovean Chronicles

Because you just can't spend your whole day programming!

Posted

with an xml structure of:

 

<Root>

<Import>

<Name>Fred Jones</Name>

<Address>101 Main Street</Address>

</Import>

<Import>

<Name>Fred Smith</Name>

<Address>103 Front Street</Address>

</Import>

</Root>

 

Imports System.Xml

Dim xmld As XmlDocument
Dim ImportNode As XmlNode
Dim KeyNode As XmlNode
Dim nodelist As XmlNodeList

'Link to XML document
xmld = New XmlDocument()
xmld.Load(ftp_files_dd.SelectedItem.Value & "/ImageKeys.Xml")

'Get the list of Import nodes
nodelist = xmld.SelectNodes("/Root/Import")

For Each ImportNode In nodelist
   ' Get attribute by using:
   ' MyVar = ImageNode.Attributes.GetNamedItem("MyAttributeName").Value

   '..... Your code .....

       For Each KeyNode In ImageNode.ChildNodes
               'Get sub node values here by using:
               ' KeyValueVar = KeyNode.InnerText

               '..... Your code .....
       Next

Next

 

Not sure if this is what you were looking for, but maybe it will help..?

Bypass your proxy and get anonymous internet surfing FREE!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...