If clsXMLRead.GetChildNode(intCount - 1, False, strNodeName, strValue) Thenĭebug.Print "Child Node : " & intCount & " " & strValue ' Get all the child nodes of the current node by referencing it by index ' Comments: Read and search portions of an XML file or text with VBA and VB6. StrValue = clsXMLRead.GetNextNode(strNodeName)
' If there's no error, you can read the contents of the fileĭebug.Print "First Child: " & clsXMLRead.FirstChildĭebug.Print "XML Root : " & clsXMLRead.Root StrError = clsXMLRead.LoadXMLString(strXML, lngError) ' This function can be run if you have the Geospatial module modGoogleMapsAPI loaded 'strXML = GoogleGeocodeXML("White House") ' If you have the file in memory, you can load it without creating a physical file. StrError = clsXMLRead.LoadXMLFile(mcstrXMLFile, lngError) ' If you have an XML file on disk, you can load it like this: ' Comments: Read all the contents of an XML file or text string using VBA and VB6. Private Const mcstrXMLFile As String = "C:\Total Visual SourceBook 2013\Samples\white-house.xml" ' Then run either of the procedures by putting the cursor in the procedure and pressing: ' F5 to run it, or ' F8 to step through it line-by-line (see the Debug menu for more options) ' View the results in the immediate window
' ' To use this example, create a new module and paste this code into it. ' Example of using the CXMLFileRead class to read XML files in VBA and VB6. Get the node value by calling it explicitly or searching for it. Get the number of siblings for the current node. Get the number of child items in the current node. Optionally resets the current node to the new node if it was found. Get the name and value of the next sibling node. Optionally reset the current node to the new node if it was found. Get the name and value of the next child node. Use the GetChildNodeCount procedure to get the number of child nodes for the current node. Optionally reset the current node to the new node if it wasįound. Get the name and value of the specified child node by index. Get all the child nodes, then the sibling nodes, and then back to the parent level. Get the number of nodes in the current node. Open the named text file and return its contents as a string. Load the XML file as a string rather than loading it from a physical file on disk. Load the XML file from a physical file on disk. Get the FirstChild of the XML file which should show the version info. public static string FormatNumber (object? Expression, int NumDigitsAfterDecimal = -1, IncludeLeadingDigit =, UseParensForNegativeNumbers =, GroupDigits = ) public static string FormatNumber (object Expression, int NumDigitsAfterDecimal = -1, IncludeLeadingDigit =, UseParensForNegativeNumbers =, GroupDigits = ) static member FormatNumber : obj * int * * * -> string Public Function FormatNumber (Expression As Object, Optional NumDigitsAfterDecimal As Integer = -1, Optional IncludeLeadingDigit As TriState =, Optional UseParensForNegativeNumbers As TriState =, Optional GroupDigits As TriState = and private variables for the CXMLFileRead class. Returns an expression formatted as a number.