This article explains how to import and read XML documents using VBScript and HTML 5.
Figure 1: XML reader home page
Step 1
- Open Notepad.
- Add the following XML code.
- <SERVER>
- <INTERFACE>
- <PORT>1</PORT>
- <IPADDRESS>10.100.4.9</IPADDRESS>
- <NETMASK>255.255.224.0</NETMASK>
- </INTERFACE>
- <INTERFACE>
- <PORT>2</PORT>
- <IPADDRESS>10.100.4.10</IPADDRESS>
- <NETMASK>255.255.224.0</NETMASK>
- </INTERFACE>
- </SERVER>
- Save the file with the extension “.xml”.
Step 2
- Open Notepad.
- Add the following HTML code:
- <! DOCTYPE html>
- <html>
- <head>
- <title>Page Title</title>
- <style>
- h1
- {
- color: #05E395;
- }
- fieldset {
- font-family: sans-serif;
- border: 5px solid #05E395;
- background: #ddd;
- border-radius: 5px;
- padding: 15px;
- }
- fieldset legend {
- background: #0BDB9D;
- color: #fff;
- padding: 5px 10px ;
- font-size: 32px;
- border-radius: 5px;
- box-shadow: 0 0 0 5px #ddd;
- margin-left: 20px;
- }
- </style>
- <script language="vbscript" type="text/vbscript">
- Sub Handlechange()
- MsgBox "File Imported Sucessfully”, vbInformation
- End Sub
- Sub ExportXML
- Dim ObjXML
- Dim fileinput
- Dim Root
- Dim NodeList
- Dim Msg
- Dim port
- Dim ip
- Dim nextmask
- Set ObjXML = CreateObject ("Microsoft.XMLDOM")
- ObjXML.async = False
- fileinput = Document.getElementById ("browse").Value
- ObjXML.load(fileinput)
- Set Root = ObjXML.documentElement
- Set NodeList = Root.getElementsByTagName("INTERFACE")
- For Each Elem In NodeList
- Set port = Elem.getElementsByTagName ("PORT") (0)
- Set ip = Elem.getElementsByTagName ("IPADDRESS") (0)
- Set netmask= Elem.getElementsByTagName ("NETMASK") (0)
- Msg ="[PORT :]" & port.Text & vbNewLine
- Msg = Msg & "[IP ADDRESS :]" & ip.Text & vbNewLine
- Msg = Msg & "[NETMASK :]" & netmask.Text
- MsgBox Msg
- Next
- MsgBox "Data Read Sucessfully”, vbInformation
- End Sub
- </script>
- </head>
- <body>
- <form>
- <section style="margin: 10px ;">
- <fieldset style="min-height:100px;">
- <legend><b>CsharpCorner </b> </legend>
- <center>
- <h1>XML Reader</h1>
- <img src="C:\Users\Karthikeyan.K\Desktop\File_type_Extension_22-256.png" alt="View" style="width:218px;height:256px;">
- <br>
- <br>
- <input type="file" id="browse" name="fileupload" onChange="Handlechange()"/>
- <br>
- <br>
- <input type="button" value="Export" id="Export" onclick="ExportXML()"/>
- </center>
- <label> <br/> </label>
- <label> <br/> </label>
- </fieldset>
- </form>
- </body>
- </html>
- Save the file with extension the “.html”.
Output
- Open the HTML document.
- Click the browse button.

Figure 2: Browse the XML document - Choose the XML document.

Figure 3: Select the XML document
Figure 4: File Imported Successfully - Press the Export button.

Figure 5: XML document Export
Figure 6: XML data Output 1
Figure 7: XML data Output 2
Figure 8: Data Read Successfully
Conclusion
Thanks for reading. I hope you liked this article. Please provide your valuable suggestions.

Bhuvanesh MohankumarPosted May 4, 2016, 2:44 PM
Good one...
Karthikeyan KPosted Aug 22, 2015, 9:25 PM
Thank you Santhakumar Munuswamy sir
Santhakumar MunuswamyPosted Aug 22, 2015, 7:52 AM
Good Article. Thanks for sharing
Karthikeyan KPosted Aug 20, 2015, 6:45 AM
Thank you Sibeesh sir
Sibeesh VenuPosted Aug 20, 2015, 6:26 AM
Nice Share
Karthikeyan KPosted Aug 20, 2015, 1:45 AM
Thank you Ankit sir
Ankit BansalPosted Aug 20, 2015, 1:44 AM
good one...
Karthikeyan KPosted Aug 19, 2015, 11:10 PM
Thank you Arjunan sir
Karthikeyan KPosted Aug 19, 2015, 11:10 PM
Thank you rakesh sir
Arjunan SelvamPosted Aug 19, 2015, 9:15 PM
Hi dude..It is really nice..keep up the good work
RakeshPosted Aug 19, 2015, 1:26 PM
good work
Karthikeyan KPosted Aug 19, 2015, 11:49 AM
Thank you Gopi sir
Gopi ChandPosted Aug 19, 2015, 11:20 AM
Great
Karthikeyan KPosted Aug 19, 2015, 9:08 AM
Thank you Vaikesh K P sir
Vaikesh K PPosted Aug 19, 2015, 9:06 AM
Nice :)
Karthikeyan KPosted Aug 19, 2015, 8:48 AM
Thank you Sumit Joshi sir
Karthikeyan KPosted Aug 19, 2015, 8:48 AM
Thank you Mohammed sir
Sumit JoshiPosted Aug 19, 2015, 8:44 AM
Nice Share...
Mohammed IbrahimPosted Aug 19, 2015, 8:43 AM
nice article
Karthikeyan KPosted Aug 19, 2015, 8:41 AM
Thank you Rajeesh sir...
Rajeesh MenothPosted Aug 19, 2015, 8:13 AM
Nice One Buddy