Topic
  • 3 replies
  • Latest Post - ‏2019-06-13T18:55:29Z by DTmann
clhoover
clhoover
10 Posts

Pinned topic Parsing CDATA from XML in DXL

‏2019-06-06T21:29:45Z | cdata dxl; xmlparser;

We're building an XML parser for a tool we're working on in DXL and we're running into an issue parsing the information. We've been using this group of functions to parse the XML and so far everything has been working just fine:

DOM_Document_ getDocumentBuffer_ (DOM_Document_, Buffer&)
string getStringAttribute_ (DOM_Element_, string)
string getElementName_ (DOM_Element_)
string setStringAttribute_ (DOM_Element_, string, string)
void ::do (DOM_Element_&, DOM_Element_, void)
void ::do (DOM_Element_&, DOM_Element_, void)
bool hasAttribute_ (DOM_Element_, string)
bool hasChildElements_ (DOM_Element_)
DOM_Element_ getDocumentElement_ (DOM_Document_)
string getElementText_ (DOM_Element_)
DOM_Document_ parseXMLBuffer_ (Buffer)
DOM_Document_ parseXMLString_ (string)

Although, when we get to a CDATA block, we start to run into issues. We assume we would be able to use the getElementText_(DOM_Document_) method to get the nested text but that returns nothing.

Any direction would be greatly appreciated. Here's the XML snippet that we're working with:

 <xmlTag
        att = "a"
        btt = "b"
        ctt = "c" >
        <![CDATA[...]]>
  </xmlTag>
  • DTmann
    DTmann
    2 Posts
    ACCEPTED ANSWER

    Re: Parsing CDATA from XML in DXL

    ‏2019-06-13T18:55:29Z  
    • O.Wilkop
    • ‏2019-06-13T18:33:09Z

    I don't think such a method exists in dxl itself, if you really need to work with xml and need cdata sections parsed you can instead go the route of using MSXML using ole automation. Its a little trickier to work with (unless you build yourself a few wrapper/helper functions), but it has the benefit of having all the features of MSXML, including xpath and xsl transformations.

     

    Some general documentation can be found at https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms764730(v=vs.85) 

     

    Of course you'll have to adapt the examples to dxl, but that should work similar to excel/word ole automation.

    Thank you for your response. I was able to find a way around by using a third party found here: https://github.com/domoran/dxlstdlib - in particular the XMLDocument.inc file

  • DTmann
    DTmann
    2 Posts

    Re: Parsing CDATA from XML in DXL

    ‏2019-06-13T15:15:56Z  

    I'm facing a similar issue as well. Any direction would be greatly appreciated :) Thanks in advance!

  • O.Wilkop
    O.Wilkop
    125 Posts

    Re: Parsing CDATA from XML in DXL

    ‏2019-06-13T18:33:09Z  

    I don't think such a method exists in dxl itself, if you really need to work with xml and need cdata sections parsed you can instead go the route of using MSXML using ole automation. Its a little trickier to work with (unless you build yourself a few wrapper/helper functions), but it has the benefit of having all the features of MSXML, including xpath and xsl transformations.

     

    Some general documentation can be found at https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms764730(v=vs.85) 

     

    Of course you'll have to adapt the examples to dxl, but that should work similar to excel/word ole automation.

  • DTmann
    DTmann
    2 Posts

    Re: Parsing CDATA from XML in DXL

    ‏2019-06-13T18:55:29Z  
    • O.Wilkop
    • ‏2019-06-13T18:33:09Z

    I don't think such a method exists in dxl itself, if you really need to work with xml and need cdata sections parsed you can instead go the route of using MSXML using ole automation. Its a little trickier to work with (unless you build yourself a few wrapper/helper functions), but it has the benefit of having all the features of MSXML, including xpath and xsl transformations.

     

    Some general documentation can be found at https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms764730(v=vs.85) 

     

    Of course you'll have to adapt the examples to dxl, but that should work similar to excel/word ole automation.

    Thank you for your response. I was able to find a way around by using a third party found here: https://github.com/domoran/dxlstdlib - in particular the XMLDocument.inc file