Solved

XML Getting Data Out of a Tag - Visual Basic

Posted on 2004-10-20
2
187 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
[X]
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
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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).
Progress

695 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