From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目

---
 src/components/bpmnProcessDesigner/src/utils/xml2json.js |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/src/components/bpmnProcessDesigner/src/utils/xml2json.js b/src/components/bpmnProcessDesigner/src/utils/xml2json.js
new file mode 100644
index 0000000..fe1a52f
--- /dev/null
+++ b/src/components/bpmnProcessDesigner/src/utils/xml2json.js
@@ -0,0 +1,50 @@
+function xmlStr2XmlObj(xmlStr) {
+  let xmlObj = {}
+  if (document.all) {
+    const xmlDom = new window.ActiveXObject('Microsoft.XMLDOM')
+    xmlDom.loadXML(xmlStr)
+    xmlObj = xmlDom
+  } else {
+    xmlObj = new DOMParser().parseFromString(xmlStr, 'text/xml')
+  }
+  return xmlObj
+}
+
+function xml2json(xml) {
+  try {
+    let obj = {}
+    if (xml.children.length > 0) {
+      for (let i = 0; i < xml.children.length; i++) {
+        const item = xml.children.item(i)
+        const nodeName = item.nodeName
+        if (typeof obj[nodeName] == 'undefined') {
+          obj[nodeName] = xml2json(item)
+        } else {
+          if (typeof obj[nodeName].push == 'undefined') {
+            const old = obj[nodeName]
+            obj[nodeName] = []
+            obj[nodeName].push(old)
+          }
+          obj[nodeName].push(xml2json(item))
+        }
+      }
+    } else {
+      obj = xml.textContent
+    }
+    return obj
+  } catch (e) {
+    console.log(e.message)
+  }
+}
+
+function xmlObj2json(xml) {
+  const xmlObj = xmlStr2XmlObj(xml)
+  console.log(xmlObj)
+  let jsonObj = {}
+  if (xmlObj.childNodes.length > 0) {
+    jsonObj = xml2json(xmlObj)
+  }
+  return jsonObj
+}
+
+export default xmlObj2json

--
Gitblit v1.8.0