Announcement

Collapse
No announcement yet.

Dealing with complex XML structures

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dealing with complex XML structures

    I am having the devil of the time using the XML functions to parse and/or update an XML script. For example, here are the first few lines. I am trying to retrieve and/or update the name of the SQL Server and database.

    Code:
    <?xml version="1.0"?>
    <configuration>
      <appSettings>
        <add key="SQLServer" value="NEWDEV6\SQLEXPRESS" />
        <add key="Database" value="NLM" />
      </appSettings>
    For example, is "SQLServer" an Attribute, an Element or a Value? Same for "NEWDEV6\SQLEXPRESS". I have tried treating them all different ways with no luck.

    Can someone give me an example of how I would retrieve:
    • Name of the SQL Server instance
    • Name of the database


    Similarly, an example of how I would update:
    • Name of the SQL Server instance
    • Name of the database


    I have ended up parsing the file with String functions, but I know that is not the way to do it. I am using the latest SUF: 9.5.

    Thanks.

  • #2
    I believe this is what you are asking?

    Click image for larger version

Name:	SCRN-2016-01-09-01.png
Views:	1
Size:	36.1 KB
ID:	284365

    Ulrich

    Comment


    • #3
      Thanks, Ulrich. That seems to do it. Although I can't say I really understand it.

      You are only using GetAttribute and SetAttribute. Where would something like GetValue or SetValue be used in this situation?

      Comment


      • #4
        You aren't working with values, but with attributes. You won't be using XML.GetValue() or XML.SetValue() for setting or retrieving the data in the XML you provided. In the help file, there is a chapter explaining XML values, attributes, etc. - it explains these notions much better than I could possibly do here.

        Ulrich

        Comment

        Working...
        X