Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

XML Getting Data Out of a Tag - Visual Basic

Posted on 2004-10-20
2
179 Views
Last Modified: 2013-11-19
The code below is part of an XML document I'm trying to get data from.  It looks like the "Applications" tag houses all of the data instead of the data being outside the tag or part of its own child tag.  I'm not quite sure how to access the values (from VB) in items like "AppID" and "BranchID"

Thanks for your help.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="D:\vbPrograms\APPROImport\APPROProcessing\snapshot.xsl"?>
<Applications OLDAPPROID="0"  AppID="111111"  AppStatus="C"  AppLockUserNum="0"  CBLockUserNum="0"  FaxLockUserNum="0"  DateAppEntryStart="5/5/2004 12:13:58 PM"  DateAppEntryCompleted="5/5/2004 12:15:43 PM"  DateAppCompleted="5/5/2004 12:23:07 PM"  DateAppCancelled=""  DateAppReceived="5/5/2004 12:13:00 PM"  DateCBStart="5/5/2004 12:13:02 PM"  DateCBComplete="5/5/2004 12:13:50 PM"  DateSentAnalyst="5/5/2004 12:14:03 PM"  PersonnelID="2"  EmployID=""  SourceID="3"  FromCode="0"  ToCode="1"  FromUser="2"  ToUser="509"  InstantResp="R"  PrimTeamNum="0"  BranchID="9"  SameDay=" "  LastRouteDate="5/5/2004 12:42:08 PM"  ReferenceNum=""
0
Comment
Question by:Whah
2 Comments
 
LVL 3

Expert Comment

by:tomv011397
ID: 12360399
these are all Attributes of the Element. Retrieve using the Attribute read, not the element read.

Tom
0
 
LVL 1

Accepted Solution

by:
173234 earned 500 total points
ID: 12381814
Whah, try the code below.  (Make sure that your Applications tag is properly closed - in the post it is not closed properly).

Dim objDoc As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMNode
Dim objAttrib As MSXML2.IXMLDOMAttribute


   Set objDoc = New MSXML2.DOMDocument
   
   ' Load your XML here, with
   ' objDoc.loadXML strMyXMLString
   ' or
   ' objDoc.load strMyXMLFileName
   
   Set objNode = objDoc.selectSingleNode("Applications")
   
   Set objAttrib = objNode.Attributes.getNamedItem("BranchID")
   
   MsgBox objAttrib.Value
   
Good luck,
RS
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This is an explanation of a simple data model to help parse a JSON feed
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question