Read Values returned from ConfigServer

Hi guys,
smashing my head for 2 days and can’t see my error…so I connected to ConfigServer, send a request and it returns (yay! xml! values needed!)
And got stuck lol

Trying to capture the 853 from:


<DBID value="853" />

My code:


XDocument resultDocument = objectsRead.ConfObject; //Capture the XML part of the object
var temp = resultDocument.Descendants("DBID").Select(x => "DBID " + x.Attribute("value").Value).ToList();

And I need to catch the DBID to send it to another CfgQuery…BUT the read of this value fails…
I think it has to do something with the UTF8…I tried many ways and same issue.
Anybody has a code to read these values and a little slap to me to understand why am I failing so miserably?

XML is:


<?xml version="1.0" encoding="utf-16"?>
<ConfData xmlns="http://schemas.genesyslab.com/Protocols/Configuration/ConfServer/2005/">
  <CfgPerson>
    <DBID value="853" />
    <tenantDBID value="101" />
    <lastName value="Rodrigues Geske" />
    <firstName value="Eduardo" />
    <employeeID value="T01039" />
    <userName value="T01039" />
    <password value="81DC9BDB52D04DC20036DBD8313ED055" />
    <isAgent value="2" />
    <CfgAgentInfo>
      <placeDBID value="0" />
      <skillLevels>
        <CfgSkillLevel>
          <skillDBID value="104" />
          <level value="0" />
        </CfgSkillLevel>
      </skillLevels>
      <agentLogins>
        <CfgAgentLoginInfo>
          <agentLoginDBID value="277" />
          <wrapupTime value="0" />
        </CfgAgentLoginInfo>
      </agentLogins>
      <capacityRuleDBID value="0" />
      <siteDBID value="0" />
      <contractDBID value="0" />
    </CfgAgentInfo>
    <isAdmin value="1" />
    <state value="1" />
  </CfgPerson>
</ConfData>

Thanks!

hi,

I had to do something similar but I was looking for the isAgent. I’ve modified it slightly for you so please don’t take this as 100% working but hopefully this helps?

BTW I’m not strong in XML parsing so please don’t laugh if there is a far easier way to do this. I was happy when I got it to work.

Dim varObjectsRead As EventObjectsRead = varMessage
Dim varNavigator As XPathNavigator = varObjectsRead.ConfObject.CreateNavigator()
Dim varNodes As XPathNodeIterator = varNavigator.Select(“//*”)

                Dim xdoc As New XmlDocument
                varNodes.MoveNext()
                varNavigator = varNodes.Current.Clone
                Dim varXML As String = varNavigator.InnerXml

                'load the XML string into an XML document
                xdoc.LoadXml(varXML)

                Dim xNode As XmlNode = xdoc.FirstChild
                'navigate to the attributes
                xNode = xNode.FirstChild

                'cycle through attributes until finding the "DBID" 
                Dim varXMLValue As String
                Do Until xNode Is Nothing ' after going to the end the variable will switch to nothing
                If XNode.Name = "DBID" Then 
                     varDBIDValue = xNode.Attributes(0).Value.ToString
                     xNode = xNode.NextSibling
                Loop
1 Like

Nice! Thanks!
Will try it tomorrow! I promised myself no coding this weekend :wink:

1 Like

Is there any exact reason for using RequestReadObjects? It is possible to use Cfg queries, that returns objects and not XML. So, it is more easily to “parse” retrieved information

2 Likes

Yup, I got it later :wink: I’m now using that method.
Thanks

1 Like