XML 名称不能以“=”字符开头
XML Name Cannot Begin with the "=" Character
我已经通读了 of % 字符,但似乎其他问题可以在 header 行中解决。 XML 中是否存在某些不允许的字符,或者我是否需要以其他方式格式化文档(在我的例子中,“=”字符在尝试用 C# 读取文档时给我带来了麻烦)?
Name cannot begin with the character ' ',也类似,但仍由 header.
修复
XElement nodes = XElement.Load(filename);
XML 的结构如下:
<?xml version="1.0" encoding="utf-8"?>
<offer>
<data id="Salary">
<ocrstring>which is equal to ,000.00 if working 40 hours per week</ocrstring>
<rule>.*(([+-]?$[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}))</rule>
<output></output>
</data>
<data id="Hours">
<ocrstring></ocrstring>
<rule>"(?<=working).*?(?=hours)"</rule> <!-- Error Occurring Here -->
<output>bob</output>
</data>
<data id="Location">
<ocrstring></ocrstring>
<rule>Regex2</rule>
<output>LongWindingRoad222</output>
</data>
</offer>
如何解析 XML 文档而不出现无法以字符开头“=”错误
您需要为所有 <rule>
元素使用 CDATA 部分。
What does <![CDATA[]]> in XML mean?
XML
<?xml version="1.0" encoding="utf-8"?>
<offer>
<data id="Salary">
<ocrstring>which is equal to ,000.00 if working 40 hours per week</ocrstring>
<rule><![CDATA[.*(([+-]?$[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}))]]></rule>
<output></output>
</data>
<data id="Hours">
<ocrstring></ocrstring>
<rule><![CDATA["(?<=working).*?(?=hours)"]]></rule>
<!-- Error Occurring Here -->
<output>bob</output>
</data>
<data id="Location">
<ocrstring></ocrstring>
<rule>Regex2</rule>
<output>LongWindingRoad222</output>
</data>
</offer>
我已经通读了
Name cannot begin with the character ' ',也类似,但仍由 header.
修复XElement nodes = XElement.Load(filename);
XML 的结构如下:
<?xml version="1.0" encoding="utf-8"?>
<offer>
<data id="Salary">
<ocrstring>which is equal to ,000.00 if working 40 hours per week</ocrstring>
<rule>.*(([+-]?$[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}))</rule>
<output></output>
</data>
<data id="Hours">
<ocrstring></ocrstring>
<rule>"(?<=working).*?(?=hours)"</rule> <!-- Error Occurring Here -->
<output>bob</output>
</data>
<data id="Location">
<ocrstring></ocrstring>
<rule>Regex2</rule>
<output>LongWindingRoad222</output>
</data>
</offer>
如何解析 XML 文档而不出现无法以字符开头“=”错误
您需要为所有 <rule>
元素使用 CDATA 部分。
What does <![CDATA[]]> in XML mean?
XML
<?xml version="1.0" encoding="utf-8"?>
<offer>
<data id="Salary">
<ocrstring>which is equal to ,000.00 if working 40 hours per week</ocrstring>
<rule><![CDATA[.*(([+-]?$[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}))]]></rule>
<output></output>
</data>
<data id="Hours">
<ocrstring></ocrstring>
<rule><![CDATA["(?<=working).*?(?=hours)"]]></rule>
<!-- Error Occurring Here -->
<output>bob</output>
</data>
<data id="Location">
<ocrstring></ocrstring>
<rule>Regex2</rule>
<output>LongWindingRoad222</output>
</data>
</offer>