473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Tired and dumb. XML & the DOM

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

Aug 21 '06 #1
1 1586
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


ni*******@gmail.com wrote:
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
Aug 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a...
0
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a...
4
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know...
4
by: Stelrad Doulton | last post by:
Hi, Apologies if this isn't the correct forum. I am writing a communication solution (actually on the Compact Framework) based on HttpWebRequests hooking up with custom handlers on the...
2
by: Bill Nguyen | last post by:
I would like to add a new VB.NET project using the same folder being used by another project so that I can share several forms already creaded by the other project. However, .NET created a new...
16
by: CMM | last post by:
Is it me or has anyone noticed that F1 is really dumb in VS2005. Since VB3 I have been able to click F1 on an ambiguous method in code and the IDE automatically determines the type based on the...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
25
by: mdh | last post by:
I have looked this up in the FAQ, and still do not have a nice understanding of it. If I have defined a function in foo.c, and if, for the sake of argument have foo.h contain that function's...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.