Как обновить JSON строку в xml Атрибут в php - PullRequest
1 голос
/ 12 февраля 2020

Это мой XML

<client runid="1">
    <div accordionid="1" parentdivclass="col-md-12 form-inline posLabelEle cust-align" type="div" lablename-class="col-md-2 heading form-group" labelnameflag="false" lablename="Size Details" tablerowhideflag="0" tablerowhideid="" manitory="0" status="true" dbaccess="0">
                            <input type="table" fieldtype="input" fldinput-class="col-md-8 form-group " field-class="readinputdata" fldpostid="cost" fldpostname="cost" fldmanitory="0" flddefaultbodyvalue="0" flddefaultheadvalue="SMALL" fldreadonly="0" dbtablerunid="epfsd_id" placeholder="" defaultflag="0" defaultvalue="" input-class="col-md-10 tableWidth" conditionflagnames="" serialnoflag="true" multirowtableFlag="true" mtablebody='{"_":{"orderby":"Size","value":"epfsd_fabric_size_unit_count","inputtype":"input","rowspan":"","orderby":"epfsd_fabric_size","parentreadingflag":"0","childreadingflag":"1","includeflag":"false","includefield":[{"total":{"value":0,"inputtype":"text","rowspan":"","orderby":"epfsd_fabric_size","parentreadingflag":"0","childreadingflag":"1"}}]}}' mtableheader='[{"Size":{"value":"epfsd_fabric_size","inputtype":"text","includeindex":"true"}}]' tableheader="Client-ID,Client-Code,Client-Name" dbtablename="epo_po_fabric_size_details" dbcolumnname="epfsd_fabric_size_unit_count" tablefunction="tableconstruct()" tablewidth="0" tablehight="0" tablehead_span='{}' tablebody_span="" col_disabled="Client-ID" postid="tableData" postname="tableData" posttblbody= "tableDataBdy" posttblhead="tableDataHd" tablehdclass="" tablebdyclass="" tableClass="table table-bordered"></input>
                        </div>
</client>

Добавлен один атрибут с использованием xpath после того, как я сохранил с использованием XML (проверьте. xml); Как это:

$xml=simplexml_load_file("check.xml");
$result = $xml->xpath("project/client[@runid='1']");
$attr = $result[0]->addChild('template','');
$attr->addAttribute("runid","4");
$attr->addAttribute("status","true");

$xml->asXml("check.xml");

Работает нормально После того, как я сохранил.

Он будет полностью изменен следующим образом

<client runid="1">
    <div accordionid="1" parentdivclass="col-md-12 form-inline posLabelEle cust-align" type="div" lablename-class="col-md-2 heading form-group" labelnameflag="false" lablename="Size Details" tablerowhideflag="0" tablerowhideid="" manitory="0" status="true" dbaccess="0">
                            <input type="table" fieldtype="input" fldinput-class="col-md-8 form-group " field-class="readinputdata" fldpostid="cost" fldpostname="cost" fldmanitory="0" flddefaultbodyvalue="0" flddefaultheadvalue="SMALL" fldreadonly="0" dbtablerunid="epfsd_id" placeholder="" defaultflag="0" defaultvalue="" input-class="col-md-10 tableWidth" conditionflagnames="" serialnoflag="true" multirowtableFlag="true" mtablebody="{&quot;_&quot;:{&quot;orderby&quot;:&quot;Size&quot;,&quot;value&quot;:&quot;epfsd_fabric_size_unit_count&quot;,&quot;inputtype&quot;:&quot;input&quot;,&quot;rowspan&quot;:&quot;&quot;,&quot;orderby&quot;:&quot;epfsd_fabric_size&quot;,&quot;parentreadingflag&quot;:&quot;0&quot;,&quot;childreadingflag&quot;:&quot;1&quot;,&quot;includeflag&quot;:&quot;false&quot;,&quot;includefield&quot;:[{&quot;total&quot;:{&quot;value&quot;:0,&quot;inputtype&quot;:&quot;text&quot;,&quot;rowspan&quot;:&quot;&quot;,&quot;orderby&quot;:&quot;epfsd_fabric_size&quot;,&quot;parentreadingflag&quot;:&quot;0&quot;,&quot;childreadingflag&quot;:&quot;1&quot;}}]}}" mtableheader="[{&quot;Size&quot;:{&quot;value&quot;:&quot;epfsd_fabric_size&quot;,&quot;inputtype&quot;:&quot;text&quot;,&quot;includeindex&quot;:&quot;true&quot;}}]" tableheader="Client-ID,Client-Code,Client-Name" dbtablename="epo_po_fabric_size_details" dbcolumnname="epfsd_fabric_size_unit_count" tablefunction="tableconstruct()" tablewidth="0" tablehight="0" tablehead_span="{}" tablebody_span="" col_disabled="Client-ID" postid="tableData" postname="tableData" posttblbody="tableDataBdy" posttblhead="tableDataHd" tablehdclass="" tablebdyclass="" tableClass="table table-bordered"/>
                        </div>
</client>

Он заменен "вместо" ", Только в JSON Строка.

Как мне решить эту проблему?

С наилучшими пожеланиями

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...