doufeinai6081 2011-02-11 16:42
浏览 76

XML html标签问题

HI, I have this xml outout generated by a php script:

<pre><code>
<menu>
<option id="67" ddmmyyyy="11 jan 2011" text="This is a text<p> ok</p> & not only a text!!" />
</menu>
</code></pre>

the xml return an error, how to format it in the right way?

  • 写回答

3条回答 默认 最新

  • douzhangwei5265 2011-02-11 16:47
    关注

    EDIT:

    As Shikiryu said, you should use another element for your text, like this:

        <pre><code>
        <menu>    
       <option id="67" ddmmyyyy="11 jan 2011">
          <text><![CDATA[This is a text<p> ok</p> & not only a text!!"]]></text>
       </option>
        </menu>
        </code></pre>
    

    You will need to update how you extract the information slightly, but this is the correct way to do it.

    The CDATA tag tells the XML parser to ignore its contents. When you access the node the wrapping CDATA tag will not be present (IE you don't need to do anything extra to remove it).

    Original Code Sample (pre edit):

    <pre><code>
    <menu>    
    <![CDATA[<option id="67" ddmmyyyy="11 jan 2011" text="This is a text<p> ok</p> & not only a text!!" />]]>
    </menu>
    </code></pre>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog