HighTechTalks DotNet Forums  

Tired and dumb. XML & the DOM

Dotnet XML microsoft.public.dotnet.xml


Discuss Tired and dumb. XML & the DOM in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
nickjaffe@gmail.com
 
Posts: n/a

Default Tired and dumb. XML & the DOM - 08-21-2006 , 03:40 PM






Hi all,

I've spent literally hours trying to figure this one out. I'm
re-developing an app from vb6 to vb.net, and I cannot get my XML code
working. I've just started using .NET. I'm tired, highly annoyed and
this is my problem (I know it is very easy for someone who has done
this before):

My entire XML file is here - The '<CALL_12260>' tag name is dynamic
(the XML file is generated by something else), everything else stays
the same. I would like to easily read the contents of every node
selectively:

<CDC>
<CALL_12260>
<JobKey>65</JobKey>
<hTapiCall>12260</hTapiCall>
<JobMode>1</JobMode>
<JobState>1</JobState>
<ForeignTel>0044863313</ForeignTel>
<OwnerTel></OwnerTel>
<RedirectingID></RedirectingID>
<RedirectionID></RedirectionID>
<Profile>EnterpriseApplication</Profile>
<ADRKey>13</ADRKey>
<ADRText>BLEH</ADRText>
<CustomerID>13</CustomerID>
<ASPKey></ASPKey>
<ASPText></ASPText>
<ASPFound>0</ASPFound>
<ADRFound>-1</ADRFound>
<Date>21/08/2006</Date>
<Time>14:59:26</Time>
<Choices></Choices>
<Contacts></Contacts>
</CALL_12260>
</CDC>

My lame attempts at .NET - I have no idea what I'm doing with
traversing the DOM...

xmlOBJ.Load(xmlPathTXT)
xmlNodeList = xmlOBJ.SelectNodes("//CDC/*")

For Each xmlNode In xmlNodeList
xmlNode.FirstChild.NodeType
Console.WriteLine(xmlNode.ChildNodes.Count)
Next

I've just been noodling around with X number of configurations of the
above trying to get something useful. Nada.

Thanks for reading my pleas for help, apologies in advance for posting
such a stupid request.

n


Reply With Quote
  #2  
Old   
nickjaffe@gmail.com
 
Posts: n/a

Default Re: Tired and dumb. XML & the DOM - 08-22-2006 , 04:06 AM






Seem to have solved it myself. Not sure if this is the best way, but I
like it. Amazing what going to sleep can do.

FYI for future developers:



Imports System.IO
Imports System.Xml

Public Function XMLPoo()

Dim xmlPathTXT As String
Dim xmlNode As XmlNode
Dim xmlNodeList As XmlNodeList
Dim xmlRoot As XmlNode
Dim xmlNodesCollection As New Collection

xmlPathTXT = "myXML.xml"
xmlOBJ.Load(xmlPathTXT)
xmlRoot = xmlOBJ.DocumentElement
xmlNodeList = xmlRoot.SelectNodes("/CDC/*/*")

For Each xmlNode In xmlNodeList
xmlNodesCollection.Add(xmlNode.InnerText.ToString,
xmlNode.Name.ToString)
Next

Return xmlNodesCollection

End Function




nickjaffe (AT) gmail (DOT) com wrote:
Quote:
Hi all,

I've spent literally hours trying to figure this one out. I'm
re-developing an app from vb6 to vb.net, and I cannot get my XML code
working. I've just started using .NET. I'm tired, highly annoyed and
this is my problem (I know it is very easy for someone who has done
this before):

My entire XML file is here - The '<CALL_12260>' tag name is dynamic
(the XML file is generated by something else), everything else stays
the same. I would like to easily read the contents of every node
selectively:

CDC
CALL_12260
JobKey>65</JobKey
hTapiCall>12260</hTapiCall
JobMode>1</JobMode
JobState>1</JobState
ForeignTel>0044863313</ForeignTel
OwnerTel></OwnerTel
RedirectingID></RedirectingID
RedirectionID></RedirectionID
Profile>EnterpriseApplication</Profile
ADRKey>13</ADRKey
ADRText>BLEH</ADRText
CustomerID>13</CustomerID
ASPKey></ASPKey
ASPText></ASPText
ASPFound>0</ASPFound
ADRFound>-1</ADRFound
Date>21/08/2006</Date
Time>14:59:26</Time
Choices></Choices
Contacts></Contacts
/CALL_12260
/CDC

My lame attempts at .NET - I have no idea what I'm doing with
traversing the DOM...

xmlOBJ.Load(xmlPathTXT)
xmlNodeList = xmlOBJ.SelectNodes("//CDC/*")

For Each xmlNode In xmlNodeList
xmlNode.FirstChild.NodeType
Console.WriteLine(xmlNode.ChildNodes.Count)
Next

I've just been noodling around with X number of configurations of the
above trying to get something useful. Nada.

Thanks for reading my pleas for help, apologies in advance for posting
such a stupid request.

n


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.