Solved

XML Getting Data Out of a Tag - Visual Basic

Posted on 2004-10-20
2
184 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

734 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