Search code examples
xpathxquerymarklogic

Marklogic - How to handle processing instruction in XML


I need to get the attribute value from XML using X Query . But this attribute like Processing instruction . So how to handle this kind of part?

     Sample XML:
        <root id="12">
        <?test date="3/1966"?>
        <?Names name="Anto. 17"?>
        <title>AUDIT</title>
        </root>

Expected output:
    date = "3/1966"

Solution

  • If it looks like a processing instruction then it is.

    For a specific processing instruction specify the target.

    data(//processing-instruction(test))
    

    All processing instructions

    data(//processing-instruction())