Download presentation
Presentation is loading. Please wait.
Published byGregory Freeman Modified over 8 years ago
1
Using Visual Basic ® With The MSXML Parser Ken Spencer Vice President 32X Corporation www.32x.com6-310
3
Cross-Platform Interop Application Data Comm Windows DNA 2000 Other Platforms Application Framework implementation Data Comm Core Standards Application Schemas FrameworksPlatform/Tools Solutions and Applications Platform/Tools Framework implementation
4
The Microsoft ® XML Engine Freely distributed Freely distributed msdn.microsoft.com/downloads/webtechn ology/xml/msxml.asp Fast parser Fast parser Great for creating and reading XML data Great for creating and reading XML data Files Streams
5
Instantiating From ASP From ASP Dim xmlDoc Dim sXML Set xmlDoc = CreateObject("microsoft.xmldom") From Visual Basic From Visual Basic Dim xDoc As MSXML.DOMDocument Set xDoc = New MSXML.DOMDocument
6
Loading XML Data Stream Data Stream Data sXML = txtXML xmlDoc.async = False xmlDoc.loadXML (sXML) File Data File DataxmlDoc.Load("f:\data\customer01.xml")
7
Asynchronous Loading Async Property Async Property Defaults to True Requires checking readyState property Returns 0 – 4 4 indicates load complete Setting Async Setting Async xmlDoc.async = False Sets to false, loading will be synchronous
8
Retrieving XML Data Extract the XML Extract the XML txtOutput = xmlDoc.xml txtOuput txtOuput Contains entire XML stream
9
Working With Nodes Understand NodeType property Understand NodeType property Node Type Example NODE_ELEMENT The Offspring The Offspring NODE_ATTRIBUTE The Offspring > The Offspring > NODE_TEXT The Offspring The Offspring NODE_PROCESSING_INSTRUCTI ON NODE_DOCUMENT_TYPE
10
Working With Nodes Retrieve elements by name Retrieve elements by name getElementsByTagName Walk through children Walk through children IXMLDOMNodeList Check out DisplayNode
11
Searching For Nodes Search for node by name Search for node by name Build nodelist Use NextMode method to walk list See cmdNextNode_Click
12
Extracting Attributes Use Attributes property Use Attributes property Returns list of attributes Returned in XMLDOMNamedNodeMap object For nodeTypes of: NODE_ELEMENT NODE_ENTITY NODE_NOTATION getNamedItem will return attribute text See cmdGetBookAttribute_Click
13
Creating XML Create an empty document Create an empty document xmlDoc.loadXML " " Loads the parser Document is empty Has one blank node (required) Use appendChild to add nodes Extract XML with XML property See cmdCreateNode_Click
14
Where Now? Tip of the iceberg Tip of the iceberg XML is moving everywhere XML is moving everywhere MSXML MSXML Works with XSL stylesheets and schmas Much more under the hood References References http://msdn.microsoft.com/xml/default.asp http://msdn.microsoft.com/xml/default.asp http://www.vbxml.com/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.