WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

MSXML

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Extract Values From XML

 Keywords:  MSXML XML 

Question:

How would I extract the first is firstname, lastname and userid?

My XML file looks like this:

<?xml Version="1.0"?>
<TKNBatch>
    <TKNHeader>
        <Version>0</Version>
        <Name>Software Token Database</Name>
        <FirstToken>000050320</FirstToken>
        <LastToken>000050320</LastToken>
        <NumTokens>1</NumTokens>
        <Secret>W7GZguWV1QQEQpueXsNgDA==</Secret>
        <DefBirth>2002/06/12</DefBirth>
        <DefDeath>2007/06/12</DefDeath>
        <DefDigits>8</DefDigits>
        <DefInterval>60</DefInterval>
        <DefAlg>0</DefAlg>
        <DefMode>0</DefMode>
        <DefPrecision>0</DefPrecision>
        <DefSmallWin>0</DefSmallWin>
        <DefMediumWin>0</DefMediumWin>
        <DefLargeWin>0</DefLargeWin>
        <DefAddPIN>0</DefAddPIN>
        <DefCopyProtection>1</DefCopyProtection>
        <DefKeypad>0</DefKeypad>
        <DefProtLevel>0</DefProtLevel>
        <DefRevision>0</DefRevision>
        <DefTimeDerivedSeeds>0</DefTimeDerivedSeeds>
        <DefAppDerivedSeeds>0</DefAppDerivedSeeds>
        <DefFormFactor>20000000</DefFormFactor>
        <HeaderMAC>9Uh02+n9C0luRSHRtX1vkg==</HeaderMAC>
    </TKNHeader>
    <TKN>
        <SN>000050320002</SN>
        <Seed>=zAPt4c9sZ00=</Seed>
        <Birth>1999/04/22</Birth>
        <Death>2009/05/31</Death>
        <AddPIN>1</AddPIN>
        <UserFirstName>firstname</UserFirstName>
        <UserLastName>lastname</UserLastName>
        <UserLogin>userid</UserLogin>
        <TokenMAC>jwN+EIfRU8w9krKHhQw56w==</TokenMAC>
    </TKN>
    <TKNTrailer>
    </TKNTrailer>
</TKNBatch>

Answer:

You may be able to use the XML Object Model :

http://msdn.microsoft.com/en-us/library/ms764730(VS.85).aspx

Here is some sample code:

sXMLFileSpec = "C:\Temp\software.db"
xmlDoc = CreateObject("MSXML2.DOMDocument.4.0")
xmlDoc.async = @false;
xmlDoc.load( sXMLFileSpec )

objNodeList = xmlDoc.getElementsByTagName("UserFirstName");
first = objNodeList.item(0).text
Message("", first)

objNodeList = xmlDoc.getElementsByTagName("UserLastName");
last = objNodeList.item(0).text
Message("", last)

objNodeList = xmlDoc.getElementsByTagName("UserLogin");
id = objNodeList.item(0).text
Message("", id)

Exit

Article ID:   W17339
File Created: 2008:10:20:14:05:18
Last Updated: 2008:10:20:14:05:18