Please plan your SCN wiki tasks accordingly.
When we have an xml string and that needs to be converted into object, we need to parse the xml string.
Like the other languages in ABAP we have standard ixml interfaces to parse and process the xml, Steps are as follows:
Interface IF_IXML (this is a factory actually) : CL_ixml=>create() – will give me and instance of the Factory. This is the main factory, which will then give me instances of other factories
Then we need to create an XML document (Interface for this is IF_IXML_DOCUMENT) – Use the factory instance obtained above to create the document (……->CREATE_DOCUMENT)
This document is to be parsed. For this we need:
- Blank Document instance (obtained from the above factory)
- Stream Factory – IF_IXML_STREAM_FACTORY ( …->CREATE_STREAM_FACTORY)
- Stream – which will then point to the actual XML that we need to parse (….>…>CREATE_ISTREAM_STRING) . No separate factory for this. The STREAM FACTORY has a method which will then help you create the stream. It is in this method that we pass the XML which needs to be parsed.
- We have to create now a Parser – IF_IXML_PARSER. The main factory itself can be used to create the parser (…….….->CREATE_PARSER : Here we have to pass Document, Stream Factory and the stream instances)
Once the Parser instance is ready, call the method PARSE. Thereafter, use the STREAM instance and call the method CLOSE, in order to close the stream
To point to a Node, we need an instance declaration of node type – IF_IXMl_NODE