【问题标题】:how to load xml file when mathml tag is exist in file through c#当文件中存在mathml标签时如何通过c#加载xml文件
【发布时间】:2016-03-10 16:57:31
【问题描述】:

这是一个 xml 文件的示例,在这个文件中给出了一些数学 ml 标记。当 XML 文件加载时,它们会在加载时间出现异常 例外是“mml”是一个未声明的前缀。第 16 行,位置 2”

xDocFile = XDocument.Load(xmlfile);

你能告诉我如何解决它吗 例如,

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book-part SYSTEM "C:\book-dtd-2.3\book.dtd">
<book-part id="" book-part-type="chapter" book-part-number="appd" xmlns:xlink="http://www.w3.org/1999/xlink">
<body>
<sec id="appd.s1">
<title>Equation 1. Response measure equals end of treatment mean minus the baseline mean</title>
<disp-formula id="appd.eq1">
<mml:math id="appd.eq2" display='block'>
<mml:mrow>
<mml:msubsup>
<mml:mi>y</mml:mi>
<mml:mi>i</mml:mi>
</mml:msubsup>
</mml:mrow>
</mml:math>
</disp-formula>
<p>Response measure equals end of treatment mean minus the baseline mean</p>
</sec>
<title>Equation 8. Likelihood of observed differences, specified as a Gaussian distribution, and standard deviation of estimate derived from the standard error of the treatment effect</title>
<disp-formula id="appd.eq14">
<italic>d</italic>
<italic>
<sub>i</sub>
</italic>~<italic>N</italic>(<italic>&#x003B8;</italic>
<italic>
<sub>i</sub>
</italic>, <italic>&#x003C3;</italic>
<sup>2</sup>)</disp-formula>
<p>Likelihood of observed differences, specified as a Gaussian distribution, and standard deviation of estimate derived from the standard error of the treatment effect</p>
<p>All unknown parameters were given weakly-informative prior distributions and estimated using Markov chain Monte Carlo<xref ref-type="bibr" rid="b4">4</xref> methods via the PyMC 2.3 software package.<xref ref-type="bibr" rid="b5">5</xref> The model was run for 200,000 iterations, with the first 150,000 samples conservatively discarded as burn-in, leaving 50,000 for inference.</p>
</sec>
</body>
</book-part>

【问题讨论】:

  • 您的 xml 无效。你需要在某处有一个 xmlns:mml 命名空间属性,除非 book.dtd 中有魔法
  • 不,不是——因为您使用的命名空间别名尚未声明。
  • 自己修复xml,很简单。打开一个 VS 项目。使用菜单:项目:添加新项目:XML 文件。将 xml 粘贴到视图中。错误将像任何其他编译器错误一样显示在错误列表中。甚至会提供修复选项。

标签: c# xml


【解决方案1】:

这里是固定代码

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book-part SYSTEM "C:\book-dtd-2.3\book.dtd">
<book-part id="" book-part-type="chapter" book-part-number="appd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="C:\book-dtd-2.3\book.dtd">
  <body>
    <sec id="appd.s1">
      <title>Equation 1. Response measure equals end of treatment mean minus the baseline mean</title>
      <disp-formula id="appd.eq1">
        <mml:math id="appd.eq2" display='block'>
          <mml:mrow>
            <mml:msubsup>
              <mml:mi>y</mml:mi>
              <mml:mi>i</mml:mi>
            </mml:msubsup>
          </mml:mrow>
        </mml:math>
      </disp-formula>
      <p>Response measure equals end of treatment mean minus the baseline mean</p>
    </sec>
    <title>Equation 8. Likelihood of observed differences, specified as a Gaussian distribution, and standard deviation of estimate derived from the standard error of the treatment effect</title>
    <disp-formula id="appd.eq14">
      <italic>d</italic>
      <italic>
        <sub>i</sub>
      </italic>~<italic>N</italic>(<italic>&#x003B8;</italic>
      <italic>
        <sub>i</sub>
      </italic>, <italic>&#x003C3;</italic>
      <sup>2</sup>)
    </disp-formula>
    <p>Likelihood of observed differences, specified as a Gaussian distribution, and standard deviation of estimate derived from the standard error of the treatment effect</p>
    <p>
      All unknown parameters were given weakly-informative prior distributions and estimated using Markov chain Monte Carlo<xref ref-type="bibr" rid="b4">4</xref> methods via the PyMC 2.3 software package.<xref ref-type="bibr" rid="b5">5</xref> The model was run for 200,000 iterations, with the first 150,000 samples conservatively discarded as burn-in, leaving 50,000 for inference.
    </p>
  </body>
</book-part>

【讨论】:

  • 请注意MathML 正式命名空间是http://www.w3.org/1998/Math/MathML
猜你喜欢
  • 2015-08-09
  • 2014-12-15
  • 2017-06-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多