[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Processing an XML file from an HTTP source

Posted on 2008-10-03
Medium Priority
Last Modified: 2013-11-05
What changes need to be made to the following code (if it can be done) to replace XmlPath with a URL. Currently it calculates the application path.

This is a VB 2005 Windows Application.
Public Sub ReadXML()
        Dim XmlPath As String = String.Empty
        Dim XmlFile As String = AppConstants.XmlFileName
        Dim XmlDoc As New XmlDocument
        Dim XmlNode As XmlNode
        Dim XmlNodes As XmlNode
        XmlPath = System.IO.Path.GetDirectoryName( _
        If XmlPath.Substring(0, 6) = "file:\" Then XmlPath = XmlPath.Substring(6)
        Dim XmlFullPath As String = System.IO.Path.Combine(XmlPath, XmlFile)
        Dim ImportJob As ImportFile
        Dim SourcePath As String = String.Empty
        Dim DestinationPath As String = String.Empty
            For Each XmlNode In XmlDoc.DocumentElement.ChildNodes
                Select Case XmlNode.Name
                    Case "COPYJOB"
                        Dim JobClass As New ImportFile
                        For Each XmlNodes In XmlNode.ChildNodes
                            With JobClass
                                Select Case XmlNodes.Name
                                    Case "SOURCEDIRECTORY"
                                        SourcePath = XmlNodes.InnerText
                                        .SourcePath = XmlNodes.InnerText
                                    Case "DESTINATIONDIRECTORY"
                                        DestinationPath = XmlNodes.InnerText
                                        .DestinationPath = XmlNodes.InnerText
                                    Case "HEADERID"
                                        .HeaderID = XmlNodes.InnerText
                                    Case "IMPORTGROUP"
                                        .ImportGroup = XmlNodes.InnerText
                                    Case "FILEPATTERN"
                                        .FileName = XmlNodes.InnerText
                                    Case "INCLUDESUBDIRS"
                                End Select
                            End With
                End Select
            ' Check for and process any existing files
            lblMessage.Text = AppConstants.MessageLabelProcessExistingFiles
            For Each ImportJob In ImportJobCollection
            lblMessage.Text = String.Empty
        Catch ex As ApplicationException
            Select Case ex.Message
                Case AppConstants.SourcePathNotFound
                    MsgBox("The source directory " + SourcePath + " could not be located." _
                        + vbCrLf + vbCrLf + "The application is being shut down.", _
                        MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Critical Error")
                Case AppConstants.DestinationPathNotFound
                    MsgBox("The destination directory " + DestinationPath + " could not be located." _
                        + vbCrLf + vbCrLf + "The application is being shut down.", _
                        MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Critical Error")
            End Select
        Catch ex As System.IO.DirectoryNotFoundException
            MsgBox("The XML configuration file " + XmlFullPath + " could not be located." _
                + vbCrLf + vbCrLf + "The application is being shut down.", _
                MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Critical Error")
        Catch ex As System.IO.IOException
            MsgBox("The XML configuration file " + XmlFullPath + " could not be located." _
                + vbCrLf + vbCrLf + "The application is being shut down.", _
                MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Critical Error")
        Catch ex As Exception
        End Try
    End Sub

Open in new window

Question by:dbbishop
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3

Expert Comment

ID: 22641709
Simply pass the url to the Load method, like so...
Note, I am using google's RSS feed in this example. This if fine since RSS is XML.
LVL 15

Author Comment

ID: 22641753
Okay, clarification:
AppConstants.XmlFileName is a constant that contains the name of the XML File.

XmlPath is a string that will eventually contin the applications' folder path, thus an example youd be:
c:\Program Files\myApplication\

AppConstants.XmlFileName will remain the same and I wish to also make XmlPath a constant that points to an internal URL on our intranet.
Assuming the location on the Intranet is \\\AppParms\EMIData\ and the file is parms.xml, what would the full URL look like?

The above example has other arguements (hl=, um=, tab=,nolr, output=) Are al required or (I assume) just the output= without the filetype (.xml).

Assisted Solution

rlh68 earned 1400 total points
ID: 22642656
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 22642664
And if you want to use your url paramters simply append them to your url, using a ? to deliminate between the url and the parameters, like so...
Depending on how you code web server to process the parameters, some or all may be required.
LVL 15

Author Comment

ID: 22642769
This is not a web app. It is a windows application written in VB 2005. We are getting ready to deploy it and I was asked if we could put the parms file in a single location accessible by all users. It is an internal application but not all users will have access to a common shared drive so I was wondering if we could put the parms file on one of our intranet servers and access it through the application. I have no web development experience.

If XmlDoc.Load("\\\AppParms\EMIData\parms.xml")
will work exactly the same way as
XmlDoc.Load("C:\Program Files\myApplication\parms.xml")
then I am fine.


Accepted Solution

rlh68 earned 1400 total points
ID: 22645288

will work as long as the users have access to the network share.

Sorry about mentioning the webserver, when I saw this line I got side tracked,

FYI, if you needed to process parameters (unless it can be done with XML and XSLT) you would need to have a web server process the request. The web server would pick off the parameters, then choose an xml datasource (possibly based on the params) to return to the application. I know this is more than you need but I wanted to mention for future reference.
LVL 15

Author Closing Comment

ID: 31502968
Thanks. The parameters were added to my reply only because they were in your original comment and I was wanting to know if they were something required as part of the load or just optional arguments. Your original example did not explicitly reference an XML file.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

650 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