Solved

XML Getting Data Out of a Tag - Visual Basic

Posted on 2004-10-20
2
171 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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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.
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now