PDA

View Full Version : [SOLVED:] Problem with read an XML file



elmnas
08-20-2014, 03:50 AM
Hello guys,

I wrote this code to read a xml




Dim docXMLDOM As DOMDocument

Set docXMLDOM = New DOMDocument
docXMLDOM.Load "C:\Test\Test.xml"

MsgBox "The first element from the root has the following values: " & docXMLDOM.ChildNodes(1).FirstChild.Text

it works fine.

if the xml file looks like this


<?xml version="1.0" encoding="utf-8" ?>
<Videos>
<Video>
<Title>The Distinguished Gentleman</Title>
<Director>Jonathan Lynn</Director>
<CastMembers>
<Actor>Eddie Murphy</Actor>
<Actor>Lane Smith</Actor>
<Actor>Sheryl Lee Ralph</Actor>
<Actor>Joe Don Baker</Actor>
<Actor>Victoria Rowell</Actor>
</CastMembers>
<Length>112 Minutes</Length>
<Format>DVD</Format>
<Rating>R</Rating>
</Video>
<Video>
<Title>Her Alibi</Title>
<Director>Bruce Beresford</Director>
<Length>94 Mins</Length>
<Format>DVD</Format>
<Rating>PG-13</Rating>
</Video>
<Video>
<Title>Chalte Chalte</Title>
<Director>Aziz Mirza</Director>
<Length>145 Mins</Length>
<Format>DVD</Format>
<Rating>N/R</Rating>
</Video>
</Videos>


the problem is.

I always recieving XML files they looks like this

see code below


<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/3.0/style/exchange.xsl"?>
<ops:world-patent-data xmlns="http://www.xxxxxx.xxx/exchange" xmlns:ops="http://xxxx.xxxxx.org" xmlns:xlink="http://www.w3.org/1999/xlink">
<ops:meta name="elapsed-time" value="2"/>
<exchange-documents>
<exchange-document system="xxx.xxx.org" family-id="xxxx" country="xx" doc-number="xxxx" kind="A1">
<bibliographic-data>
<publication-reference>
<document-id document-id-type="docdb">
<country>xx</country>
<doc-number>xxxx</doc-number>
<kind>A1</kind>
<date>20120627</date>
</document-id>
<document-id document-id-type="xxx">
<doc-number>xxxx</doc-number>
<date>20120627</date>
</document-id>

Could someone help me to modify my code so it reads the first node?
I am not expeirenced in VBA DOM etc.


Thank you in advance people.