Author Topic: Extract xml data from configuration server events  (Read 2254 times)

Offline WDev

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Extract xml data from configuration server events
« on: May 18, 2017, 05:37:18 PM »
Hi everyone,
could you please suggest a way to extract the xml document from a EventObjectCreated message like the one bellow, using getMessageAttribute("ConfObject") always returns null document, thanks for any help !
'EventObjectCreated' (74) attributes:
IATRCFG_OBJECTTYPE [int] = 25
IATRCFG_REQUESTID [int] = 0
SATRCFG_OBJECT [str] = <?xml version="1.0" encoding="UTF-8" standalone="no"?><ConfData xmlns="http://schemas.genesyslab.com/Protocols/Configuration/ConfServer/2005/"><CfgTableAccess><DBID value="207"/><tenantDBID value="101"/><name value="TAP_0_2017-05-18_18:32"/><type value="1"/><description value="Table Access created at 2017-05-18_18:32"/><dbAccessDBID value="135"/><formatDBID value="103"/><dbTableName value="CLG_0_201705181832"/><isCachable value="1"/><updateTimeout value="10"/><state value="1"/></CfgTableAccess></ConfData>
IATRCFG_FOLDERDBID [int] = 215
IATRCFG_HISTORYLOG [bool] = false
IATRCFG_TIMESTAMP [int] = 1400434335
IATRCFG_UNSOLEVENTNUM [int] = 17250

Offline David Alvarez

  • Newbie
  • *
  • Posts: 17
  • Karma: -1
Re: Extract xml data from configuration server events
« Reply #1 on: May 20, 2017, 04:29:04 PM »
Hi Wafa.
Try with this:


XDocument resultDocument = (XDocument)ObjectCreated.ConfObject;
String xml = extractXML(resultDocument);
.
.
.


protected static string extractXML(XDocument document)
        {
            StringBuilder xmlAsText = new StringBuilder();
            StringWriter stringWriter = new StringWriter(xmlAsText);
            XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);
            xmlTextWriter.Formatting = Formatting.Indented;

            document.Save(xmlTextWriter);
            String xml = xmlAsText.ToString();
            return xml;
        }