Solved

Why parse an XML file selectNodes doesnt work?

Posted on 2009-03-31
2
775 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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. …
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

707 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

14 Experts available now in Live!

Get 1:1 Help Now