Search This Blog

Monday, March 5, 2012

Get a value from the XML

Okay so this is the scenario. You've got a response from the XML request you places via Integration Broker and you want to extract the data from a specific tag for further processing. The below code will help you to accomplish the same.

&lmsgGoRequest = CreateMessage(Operation.OPERATION_NAME, %IntBroker_Request);
&lmsgGoRequest.SetXmlDoc(&lxmlDoc);
&lmsgGoResponse = %IntBroker.SyncRequest(&lmsgGoRequest);
&MyDoc = CreateXmlDoc(&lmsgGoResponse.GenXMLString());
&field1List = &MyDoc.GetElementsByTagName("EMPLID");
WinMessage(&field1List [1].NodeValue);

&field1List is the array of the tags fetched from the XML (which you have specified) and NodeValue gives you the value of the tag.

Hope it helps!

2 comments:

  1. just a quick comment. &MyDoc can be retrieved from lmsgGoResponse using the GetXmlDoc method. This is better than having to build/parse a new document from the xml string.

    Keep up the great work.

    ReplyDelete
  2. Thanks Joe. Will try that option :)

    ReplyDelete