Solved

Why parse an XML file selectNodes doesnt work?

Posted on 2009-03-31
2
778 Views
Last Modified: 2013-12-26
I'm using SelectNodes from XMLDocument (In access 2003) in order to read all of the Nodes contained in the file, but I'm having some problems to get the second and third nodes in a loop.

When using this vb code, I receive two records of the first node ("//body2")
And go on to the rest of the xml, how do I get the individual values?


The xml doc start like :  
 <?xml version="1.0" encoding="UTF-8" ?>
- <form1>
      &
      &
- <section2>
  <header2 xmlns:xfa="http://www...../schema/xfa-data/1.0/" xfa:dataNode="dataGroup" />
- <body2>
  <contactPhone>07493153</contactPhone>
  <nameOfSchool>Ffff SCHOOL</nameOfSchool>
  <position>PRINCIPAL</position>
  <type>1</type>
  <givenNames>LEISA</givenNames>
  <surname>NEATON</surname>
  <employeeNo>2145</employeeNo>
  <fullName>LEISA NEATON</fullName>
  <location>School based</location>
  </body2>
- <body2>
  <contactPhone>07493153</contactPhone>
  <nameOfSchool>Fasdf</nameOfSchool>
  <position>TEACHER</position>
  <type>1</type>
  <givenNames>Barak</givenNames>
  <surname>OBAMA</surname>
  <employeeNo>2189</employeeNo>
  <fullName>Barak OBAMA</fullName>
  <location>School based</location>
  </body2>
  <addBody2 xmlns:xfa="http://www...../schema/xfa-data/1.0/" xfa:dataNode="dataGroup" />
  <Validate2 xmlns:xfa="http://www..../schema/xfa-data/1.0/" xfa:dataNode="dataGroup" />
  </section2>

&
&


    For Each nodeR In xmlFile.selectNodes("//body2")
        rst.AddNew
        rst!fldAppID = AppID
        rst!fldsName = nodeR.selectSingleNode("//surname").Text
        rst!fldgNames = nodeR.selectSingleNode("//givenNames").Text
        rst!fldPosition = nodeR.selectSingleNode("//position").Text
        rst!fldEORC = nodeR.selectSingleNode("//type").Text
        rst!fldEmployeeID = nodeR.selectSingleNode("//employeeNo").Text
        rst!fldPh = nodeR.selectSingleNode("//contactPhone").Text
        rst!fldSchoolDepartm = nodeR.selectSingleNode("//nameOfSchool").Text
        rst.Update
    Next nodeR


...

 Dim nodeR As IXMLDOMNode
 

    For Each nodeR In xmlFile.selectNodes("//body2")

        rst.AddNew

        rst!fldAppID = AppID

        rst!fldsName = nodeR.selectSingleNode("//surname").Text

        rst!fldgNames = nodeR.selectSingleNode("//givenNames").Text

        rst!fldPosition = nodeR.selectSingleNode("//position").Text

        rst!fldEORC = nodeR.selectSingleNode("//type").Text

        rst!fldEmployeeID = nodeR.selectSingleNode("//employeeNo").Text

        rst!fldPh = nodeR.selectSingleNode("//contactPhone").Text

        rst!fldSchoolDepartm = nodeR.selectSingleNode("//nameOfSchool").Text

        rst.Update

    Next nodeR

Open in new window

0
Comment
Question by:smayshar
2 Comments
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 500 total points
ID: 24045289
please move this question in VB zone.

Regards,
Sandeep
0
 

Author Closing Comment

by:smayshar
ID: 31646743
not answeared
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now