Using the XmlDocFactory Class
The XmlDocFactory class allows the processing of basic XML text strings that are otherwise too large to be loaded into a single XmlDoc instance.
The programmer sets specific node names to be searched for. The XmlDocFactory parses the input string looking for nodes that match said pattern. Once found, an XmlDoc object is created from that string using the found node as the root node of the new document.
Typical usage would be to traverse the entire input string looking for all such occurrences of the target string, creating new XmlDoc objects until no more can be created. In PeopleCode, that would look similar to this:
Local XmlDocFactory &theXmlDocFactory; Local XmlDoc &theXmlDoc; Local string &findString = "Transaction"; &theXmlDocFactory = CreateXmlDocFactory(); &returnbool = &theXmlDocFactory.SetStringToParse(&inputXmlString); &theXmlDoc = &theXmlDocFactory.GetNextXmlDoc(&findString); While ( Not &theXmlDoc.IsNull) rem do something with the XmlDoc; &theXmlDoc = &theXmlDocFactory.GetNextXmlDoc(&findString); End-While;
In the preceding example, the GetNextXmlDoc method is called repeatedly until a null XmlDoc object is returned; this signifies that the XmlDocFactory object has reached the end of the input string.
There are two caveats when using the XmlDocfactory class:
The input string must remain in scope for the duration of processing. Because such strings are typically large, the factory does not make a local copy of the string. It uses the original string passed to it. If the original string goes out of scope or becomes null, the factory processing will fail.
The XmlDocFactory object must be declared as a local variable only. Component and global scope are not supported.