我在变量php中有以下字符串
<root>
<id></id>
<title>Maarch Capture Connector</title>
<width>400</width>
<height>250</height>
<center>true</center>
<fields>
<node>
<type>comboBox</type>
<id>ingoing</id>
<label>Courrier</label>
<autocomplete>false</autocomplete>
<values>
<node>
<id>Y</id>
<label>Arrivée</label>
</node>
<node>
<id>N</id>
<label>Départ</label>
</node>
</values>
<default_value>Y</default_value>
<show_id>false</show_id>
<mandatory>true</mandatory>
</node>
<node>
<type>comboBox</type>
<id>priority</id>
<label>Priorité</label>
<autocomplete>false</autocomplete>
<values>
<node>
<id>0</id>
<label>Priorité trés haute</label>
</node>
<node>
<id>1</id>
<label>Priorité haute</label>
</node>
<node>
<id>2</id>
<label>Priorité normale</label>
</node>
<node>
<id>3</id>
<label>Priorité basse</label>
</node>
</values>
<default_value>2</default_value>
<show_id>false</show_id>
<mandatory>true</mandatory>
</node>
<node>
<type>comboBox</type>
<id>services</id>
<label>Service</label>
<autocomplete>false</autocomplete>
<values>
<node>
<id>9</id>
<label>Compay SEGUNDO</label>
</node>
<node>
<id>10</id>
<label>Contract 1 for Eric SPRITZ : Life insurance</label>
</node>
<node>
<id>13</id>
<label>Contract 1 for Thomas BECK : Life insurance</label>
</node>
<node>
<id>11</id>
<label>Contract 2 for Eric SPRITZ : Home insurance</label>
</node>
<node>
<id>14</id>
<label>Contract 2 for Thomas BECK : Home insurance</label>
</node>
<node>
<id>12</id>
<label>Contract 3 for Eric SPRITZ : Car insurance</label>
</node>
<node>
<id>15</id>
<label>Contract 3 for Thomas BECK : Car insurance</label>
</node>
<node>
<id>8</id>
<label>Edith PIAF</label>
</node>
<node>
<id>1</id>
<label>Eric SPRITZ</label>
</node>
<node>
<id>5</id>
<label>Joao GILBERTO</label>
</node>
<node>
<id>6</id>
<label>Luciano PAVAROTTI</label>
</node>
<node>
<id>7</id>
<label>Maria BETHANIA</label>
</node>
<node>
<id>16</id>
<label>MARTIN HR file</label>
</node>
<node>
<id>17</id>
<label>SMITH HR file</label>
</node>
<node>
<id>3</id>
<label>Teresa CRISTINA</label>
</node>
<node>
<id>2</id>
<label>Thomas BECK</label>
</node>
<node>
<id>4</id>
<label>Tom JOBIM</label>
</node>
</values>
<show_id>false</show_id>
<mandatory>true</mandatory>
</node>
</fields>
</root>当我尝试用simplexml_load_string函数读取时
$xmlForm = simplexml_load_string($string);我知道这个错误
实体:第1行:解析器错误:预期的开始标记,“<”未找到
我不明白什么是成功。
发布于 2013-02-28 00:17:03
尝试将空标记<id></id>替换为<id/>
虽然在技术上是正确的,但它可能会使解析器崩溃。
除此之外,在我看来,它似乎是格式良好的XML。
发布于 2013-02-28 00:32:46
执行此代码:
<?php
$str =<<<XML_CONTENT
<?xml version='1.0'?>
<root>
<id></id>
<title>Maarch Capture Connector</title>
<width>400</width>
<height>250</height>
<center>true</center>
<fields>
<node>
<type>comboBox</type>
<id>ingoing</id>
<label>Courrier</label>
<autocomplete>false</autocomplete>
<values>
<node>
<id>Y</id>
<label>Arrivée</label>
</node>
<node>
<id>N</id>
<label>Départ</label>
</node>
</values>
<default_value>Y</default_value>
<show_id>false</show_id>
<mandatory>true</mandatory>
</node>
<node>
<type>comboBox</type>
<id>priority</id>
<label>Priorité</label>
<autocomplete>false</autocomplete>
<values>
<node>
<id>0</id>
<label>Priorité trés haute</label>
</node>
<node>
<id>1</id>
<label>Priorité haute</label>
</node>
<node>
<id>2</id>
<label>Priorité normale</label>
</node>
<node>
<id>3</id>
<label>Priorité basse</label>
</node>
</values>
<default_value>2</default_value>
<show_id>false</show_id>
<mandatory>true</mandatory>
</node>
<node>
<type>comboBox</type>
<id>services</id>
<label>Service</label>
<autocomplete>false</autocomplete>
<values>
<node>
<id>9</id>
<label>Compay SEGUNDO</label>
</node>
<node>
<id>10</id>
<label>Contract 1 for Eric SPRITZ : Life insurance</label>
</node>
<node>
<id>13</id>
<label>Contract 1 for Thomas BECK : Life insurance</label>
</node>
<node>
<id>11</id>
<label>Contract 2 for Eric SPRITZ : Home insurance</label>
</node>
<node>
<id>14</id>
<label>Contract 2 for Thomas BECK : Home insurance</label>
</node>
<node>
<id>12</id>
<label>Contract 3 for Eric SPRITZ : Car insurance</label>
</node>
<node>
<id>15</id>
<label>Contract 3 for Thomas BECK : Car insurance</label>
</node>
<node>
<id>8</id>
<label>Edith PIAF</label>
</node>
<node>
<id>1</id>
<label>Eric SPRITZ</label>
</node>
<node>
<id>5</id>
<label>Joao GILBERTO</label>
</node>
<node>
<id>6</id>
<label>Luciano PAVAROTTI</label>
</node>
<node>
<id>7</id>
<label>Maria BETHANIA</label>
</node>
<node>
<id>16</id>
<label>MARTIN HR file</label>
</node>
<node>
<id>17</id>
<label>SMITH HR file</label>
</node>
<node>
<id>3</id>
<label>Teresa CRISTINA</label>
</node>
<node>
<id>2</id>
<label>Thomas BECK</label>
</node>
<node>
<id>4</id>
<label>Tom JOBIM</label>
</node>
</values>
<show_id>false</show_id>
<mandatory>true</mandatory>
</node>
</fields>
</root>
XML_CONTENT;
$xmlForm = simplexml_load_string($str);
print_r($xmlForm);
echo "Everything is fine !";
?>在PHP计算机中,如:PHP在线
工作得很好,这样您的字符串初始化就会出现问题(坏的不可见的破坏者.?)
注意:添加XML头标记是最好的努力,不应忘记。
发布于 2013-03-19 00:33:17
我已经解决了我的问题。我的XML是fine...The,问题在我修改过的其他Maarch Enterprise文件中。(很抱歉迟了回复,谢谢你的帮助:)
https://stackoverflow.com/questions/15125067
复制相似问题