0

I have a xml which is generated by BPMN. It has the below code with xml tag when it is getting generated.

<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:defvar 
    xmlDoc = $.parseXMLinitions 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" 
    xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" 
    xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" 
    xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="sample-diagram" 
    targetNamespace="http://bpmn.io/schema/bpmn" 
    xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
    <!-- ......so on-->
</bpmn2:defvar>

So when i use $.parseXML to parse it, it shows error at version like

Parse error: syntax error, unexpected `version` (T_STRING) in /opt/lampp/htdocs/abc/1234.php on line 4

How can i resolve this ?

collapsar
  • 17,010
  • 4
  • 35
  • 61
Vamsi Krishna
  • 162
  • 1
  • 13
  • 1
    Have a look at [this SO answer](https://stackoverflow.com/a/10506100) - do you have php short tags turned on ? (This flag interferes with the xml prologue as it makes php parse _everything_ starting with `` ( not just ` – collapsar Jul 18 '18 at 13:55

1 Answers1

0

The code excerpt you've presented is malformed - the jQuery function call has found it's way into the xml body.

The following is parsed without problems:

xmlDoc = $.parseXML(`<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:defvar
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL"
    xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
    xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
    xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="sample-diagram"
    targetNamespace="http://bpmn.io/schema/bpmn"
    xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
    <!-- ......so on-->
</bpmn2:defvar>`);

The error message suggests you may have an issue with php generating the embedding page, specifically the short_open_tag being set in php.ini - see this SO answer.

collapsar
  • 17,010
  • 4
  • 35
  • 61