Test for an Element name in an XML file (1 Viewer)

JDB

Registered User.
Local time
Today, 08:49
Joined
Mar 10, 2013
Messages
13
How do I test for an Element name in an XML file so I can reset a loop or do something else.

I am very new to XML and want to test for an element name of
<sample>

I see there are ways to create Elements but I have not ascertained how to test for the element name.

Thanks

JDB
 

pr2-eugin

Super Moderator
Local time
Today, 16:49
Joined
Nov 30, 2011
Messages
8,494
Hello JDB.. Your description is quiet vague, could you explain what is that you are trying to do? Is this something to do with VBA? If so.. Try the InStr() Function.. It would take a string and check for the element that you are looking for..
Code:
Dim checkStr As String
checkStr = "<html><head></head><body><sample>Hello World</sample></body></html>

If [URL="http://www.techonthenet.com/access/functions/string/instr.php"]InStr([/URL]checkStr, "<sample>") <> 0 Then MsgBox("<sample> Found")
 

JDB

Registered User.
Local time
Today, 08:49
Joined
Mar 10, 2013
Messages
13
This was more of an XML question.

The Import XML does not work on the XML file I receive so just had to write some VBA code to load into a table. Simple enough using objects on the msxml6 dll. Just trying to figure out all of the methods and properties.

Seems to be 3 or 4 ways to do things without much good documentation.

This is waht actually worked for my problem.

Dim xmlDoc As MSXML2.DOMDocument60
Dim str_XmlDoc As String
Dim xmlNode As MSXML2.IXMLDOMNode
Dim xmlNodeList As MSXML2.IXMLDOMNodeList
Dim myNode As MSXML2.IXMLDOMNode
Dim str_Element As String
<snip>
str_Element = xmlNode.BaseName
<snip>


Thanks for all the suggestions

Always good material

JDB
 

Users who are viewing this thread

Top Bottom