[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

XML Getting Data Out of a Tag - Visual Basic

Posted on 2004-10-20
2
Medium Priority
?
199 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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

834 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