Parsing XML within SAP ABAP

╄→гoц情女王★ 提交于 2019-12-14 03:57:37

问题


My company is working on a project that needs to read XML files within SAP ABAP.

  1. When the XML file has no data for a particular tag it omits that data.
  2. Some tags are self closing. e.g. <tag />

The SAP developer says that to read the XML document he first parses the document into an ABAP XML structure. This process fails on point 2. He must then create an XSLT to turn that data into an internal data structure, and that fails on point 1 therefore making the task very difficult to achieve within ABAP. Is that definitely the case and is there then no way of reading the specific fields that we need?


回答1:


The best place to start with XML parsing in ABAP is the SAP XML Library.

It is arguably a really bad idea to try and write your own parsing algorithm - let someone else (SAP, in this case) do the hard work for you.




回答2:


I'd suggest you apply the XSLT first to bring the XML content into a form the ABAP processor is able to read. There's also iXML (take a look at the sample programs BCCIIXML*), but it's rather slow and cumbersome to use...




回答3:


You can just read the file (using open dataset) and then parse the XML using string functions like find. Its ugly and could be A LOT of work, but you can definitely do it.



来源:https://stackoverflow.com/questions/1765936/parsing-xml-within-sap-abap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!