Connection string in XML File With DOM or xpath

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mohammed saleh
    New Member
    • Apr 2013
    • 42

    Connection string in XML File With DOM or xpath

    What is the code for DOM OR XPATH to connect xml file connection in my code(project)
    How can I do this ,please help me ?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    depends on what language your code is in.

    Comment

    • mohammed saleh
      New Member
      • Apr 2013
      • 42

      #3
      Originally posted by Dormilich
      depends on what language your code is in.
      vb.net with asp (microsoft visual studio 2008)
      I'm sorry for later

      please help me

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        I do not know VB.NET so I cannot. Maybe the people in the .NET forum can.
        Last edited by Frinavale; Jun 6 '13, 05:16 PM. Reason: Post you were referring to in the PS section has been deleted

        Comment

        • mohammed saleh
          New Member
          • Apr 2013
          • 42

          #5
          How can I get xml file(connection string) for my code

          Please help me
          Last edited by Frinavale; Jun 6 '13, 05:17 PM. Reason: Removed plead for help to a member who is not even involved in this thread.

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            The reason I haven't answered thus far is because I am unclear on what you are trying to do.

            Since your question is vague, my answer is going to be vague as well.

            If you want to load an XML file into your application for processing you should check out the XmlDocument Class.

            You should probably also take a look at this MSDN article about How To: Load XML Data in the XML Web Server Control.

            The MSDN Library is a great resource to use whenever you are developing in any .NET language.

            -Frinny

            Comment

            • mohammed saleh
              New Member
              • Apr 2013
              • 42

              #7
              Code:
              Public Function GetXmlConnection() As String
              	Dim connection As String = ""
              	Dim xml As New XmlDocument()
              	xml.Load(HttpContext.Current.Server.MapPath("~/App_Data/XmlReadSource.xml"))
              	Dim root As XmlNode = xml.SelectSingleNode("configuration")
              	Dim child As XmlNodeList = root.ChildNodes
              	For Each c As XmlNode In child
              		If TryCast(c, XmlElement).Name = "appsettings" Then
              			Dim xnl As XmlNodeList = c.ChildNodes
              			For Each xnf As XmlNode In xnl
              				Dim xe As XmlElement = DirectCast(xnf, XmlElement)
              				If xe.GetAttribute("key") = "constr" Then
              					connection = xe.GetAttribute("value")
              				Else
              					Continue For
              				End If
              
              			Next
              		Else
              			Continue For
              		End If
              	Next
              	Return connection
              End Function

              Comment

              • mohammed saleh
                New Member
                • Apr 2013
                • 42

                #8
                Frinavale
                How to do XML Serializable for this code XML DOM connection string

                Comment

                Working...