Example Code

XML Example DataPlugin

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Diadem
  • LabVIEW

    Other

  • Toolkits and Add-Ons: NI DataFinder Server Edition 2011, LabVIEW DataFinder Toolkit 2011

Code and Documents

Attachment

Description

This example DataPlugin supports reading / importing of XML files using Microsoft MSXML.

 

How to Use

This example DataPlugin shows how XML files (Extensible Markup Language) can be read by using Microsoft MSXML. 

 

1. Download xml_example.zip. 

2. Install the URI file. You can find the VBScript file located at C:\Program Files\National Instruments\Shared\USI\plugins\DataPlugins\XML Example.

3. You can make changes to this file to read your specific XML file.

Related Links

 

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Torguin67
Member
Member
on

Hello there, 

has anyone tested the xml-plugin? I've installed the uri and try to open an xml-document but always get the error:

"Fehler in <XML Example.VBS> (Zeile: 30):
Object doesn't support this property or method: 'xDoc.documentElement.getNamedItem'"

 

Maybe somebody has an idea what I am doing wrong?

 

so here the changed original code:

 

Option Explicit

Sub ReadStore(File)

Dim xmlFile : xmlFile = File.Info.FullPath
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' open the file
OpenXMLFile xmlFile

End Sub


Sub OpenXMLFile(xmlFile)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Open MS-Xml Parser
' Create the ActiveX object for the Microsoft XML parser.
dim xDoc : set xDoc = CreateObject("MSXML2.DOMDocument.3.0")

' Try loading the XML document
If xDoc.Load(xmlFile) = False Then
' The XML document failed to load.
RaiseError "Could not load XML document!"
End If
dim originalLocale : originalLocale = GetLocale
SetLocale "en-us"

' The XML document loaded successfully, now do something interesting!

root.Properties.Add "Buchung", xDoc.documentElement.getNamedItem("Buchung")                       'this is line 30
end sub

 

used xml-file:

<?xml version="1.0"?>
<Buchung xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Buchung>12345</Buchung>
<Pruefstand>FZG</Pruefstand>
<Test>FZGA20</Test>
<Projekt>122345</Projekt>
<Code>1-2345-67-89</Code>
<LaborNr>AA/xxxxx/xxxx</LaborNr>
<OelBezeichnung>Text</OelBezeichnung>
<Kommentare>
<Kommentar>
</Kommentar>

 

<snip>
</snip>

 

</Kommentare>
</Buchung>

 

 

 

Torguin67
Member
Member
on

Correction for line 30:

root.Properties.Add "Buchung", xDoc.documentElement.getNamedItem("Buchung").nodeValue

Contributors