hi,
I've used script with slight changes from Tarun's book. My xml file in
attachment
Set xmlDoc = XMLUtil.CreateXMLFromFile("c:\example5.xml" )
Set xmlRoot = xmlDoc.GetRootElement()
Set xmlCols = xmlDoc.ChildElementsByPath("/info/person")
' ########## count future columns in the data table
If xmlCols.Count <>0 Then
Set xmlCol = xmlCols.item(1)
iCount = xmlCol.ChildElements().Count
msgbox iCount
' ######### loop thru all elements and create column's name
For i = 1 to iCount
DataTable.GlobalSheet.AddParameter
xmlCol.ChildElements.item(i).ElementName()," "
Next
' ############ loop thru all nodes
For i = 1 to xmlCols.count
Set xmlCol = xmlCols.item(i)
iCount = xmlCol.ChildElements().Count
' ########### loop thru direct childrens
For j = 1 to iCount
sParamName = xmlCol.ChildElements.item(j).ElementName()
sParamValue = xmlCol.ChildElements.item(j).Value()
DataTable.GlobalSheet.SetCurrentRow (i)
DataTable.GlobalSheet.GetParameter(sParamName).Value = sParamValue
Next
Next
End If
Ludmila.
Date: Fri, 4 Sep 2009 21:40:21 +0530
Subject: Re: Extracting Values from XML and Exporting to DataTable
From: [email protected]
To: [email protected]
DataTable.Value ("Test", dtGlobalSheet) = root.nodeName
Try it
On Fri, Sep 4, 2009 at 7:40 PM, johnthenu <[email protected]> wrote:
<abc:Title>MISS</abc:Title>
<abc:FirstName>test</abc:FirstName>
<abc:Surname>case</abc:Surname>
<abc:Gender>FEMALE</abc:Gender>
<abc:DOB>1965-12-01</abc:DOB>
<abc:MaritalStatus>SING</abc:MaritalStatus>
<abc:LocalBorn>true</abc:LocalBorn>
<abc:LocalLivingStartDate>2000-01-01</abc:LocalLivingStartDate>
<abc:Status>EMP</tpf:Status>
Hi, I want to Extract text between <Title> tag and export it to
Datatable with Column Name Title_Name…..and I want to extract text
between <FirstName> tag and export the text to Datable with column
name First_Name and so on….
I have the below script which extract all the text between the child
elements, but I just want the text between individual elements and
export it to datatable in the respective column. Any Help will be very
much appreciated.
set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async= False
xmlDoc.load("C:\Documents and Settings\get\Desktop\test.xml")
Set root = xmlDoc.documentElement
For each x in root.childNodes
DataTable.Value ("Test", dtGlobalSheet) = root.childNodes.item
(i).text
Next
Many Thanks,
<br
_________________________________________________________________
Get back to school stuff for them and cashback for you.
http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
-~----------~----~----~----~------~----~------~--~---
ÿþ<