要访问消息的内容进行读或写时,请使用解析器根据输入位流创建的树中的元素结构和排列。从树的顶部开始,按照相关的父子关系向下访问,直至到达所需的元素。
MbMessageAssembly 的 Java 访问程序 | ESQL 相关名 |
---|---|
getMessage().getRootElement() | InputRoot |
getMessage().getRootElement().getLastChild() | InputBody |
getLocalEnvironment().getRootElement() | InputLocalEnvironment |
getGlobalEnvironment().getRootElement() | Environment |
getExceptionList().getRootElement() | InputExceptionList |
以下示例显示了一条简单的 XML 消息以及将根据该消息创建的逻辑树。本示例中,该消息已使用的 WebSphere MQ 发送。该逻辑树图还显示了浏览树时需要调用的方法。
<document> <chapter title='Introduction'> 某些文本。 </chapter> </document>
MbElement root = assembly.getMessage().getRootElement(); MbElement chapter = root.getLastChild().getFirstChild().getFirstChild();