subject: A Fairly Easy Account Of Xml And Visual Basic [print this page] Visual Basic is an tremendously significant programming language and as a consequence it is worthy of deeper discussion and explanation. Nevertheless to be more accurate, Visual Basic by far the most regularly used programming language on earth.
The most obvious cause for this success is because of in great part due to the simplicity, you can make basic effects like Hello Word in just a few lines of code rather than several thousand, its easy and does the job with minimal fuss and complexity.
The most recent version of Visual Basic is Visual Basic 6, a bye product of Microsofts Visual Studio. Apparently Visual Basic offers no native support for XML, a very common and popular markup language but nevertheless, Visual Basic has been regarded by a great number of developers as an effective way to work with XML.
Although VB delivers absolutely no component or mechanism to read, write or make xml, or even a data engine to support or work with xml, you will find parsers (MSXML parser or Liquid XML Studio) which can be used to work with VB and XML while it exposes the same interfaces in VB like in XML.
XML Parsers like the Microsoft MSXML parser and Liquid XML Studio, function utilizing the DOM or Document Object Model. The DOM is constructed of five important parts, attributes,documents, elements, nodes and nodelists.
Each one of these has their own unique programmatic interfaces (specifically, DOMDocument, IXMLDOMNode, IXMLDOMNodeList, IXMLDOMElement, and IXMLDOMattribute), each of which show a number of methods and properties.
For instance, the DOMDocument interface is for handling loading and saving of XML files (through .load, .loadXML--which converts an XML structured string into an internal DOMDocument--and .save), and the IXMLDOMElement interface deals with referencing attributes, content text, and element children, and offers a beginning point for producing XPath queries.
Xpath is regarded as the popular choice for XSLT users when attempting to pick out nodes with an xmltree. This capability to pull nodes from an XML DOM is the main reason that parsers are incredibly popular, the MSXML parser can carry out Xpath queries which enable it to reference any nodes inside an xmltree employing rather sophisticated queries.
XML is hierarchical by nature and so whilst it would seem easy enough to populate and represent XML as a tree, this is simply not always the case in reality as you may not want to do so, one example is you could wish to leave out some braches or nodes.
In fact, you may simply want to develop a treeview structure that illustrates precisely the most relevant nodes, you might also wish to be able to pick the nodes, causing more in-depth information to appear in the right hand pane of your application. This is usual for most Explorer-type applications.
One of many ways in which to achieve this would be to code the necessary functionality that will show your XML, straight to your program. Having said that this isnt perfect and can actually cost time and effort when you need to recompile your application any time you want to alter the display, worst still it means messing with tons of ugly DOM code.
Your best option should be to move the layout instructions to an XSLT stylesheet which will afterward format the xml data into a format well suited for processing.
As an alternative you need to use any of the widely used xml vb parsers or if you might want to generate code from your XML, try Liquid XML Visual Basic to generate your VB code automatically.