我第一次尝试写了这段XML,但不知何故它给出了一个错误。 我已经阅读了有关该主题的另一篇文章,它告诉您有 1 个根父级;就我而言,这将是目录。我还为属性指定了一个没有空格的名称。知道问题可能是什么吗?
任何帮助将不胜感激。
<?xml version="1.0"?>
<Catalog>
<EnginePart1>
<petrolType>Diesel</petrolType>
<GeneralInfo>
<CarBrand>ALFA ROMEO</CarBrand>
<NoOfCyl>4</NoOfCyl>
<BoreDia>69.6mm</BoreDia>
<Capacity>1,248cc</Capacity>
</GeneralInfo>
<Image>
<file type="PNG">Capture.PNG3.PNG</file>
</Image>
<LinerKit>
<ReferenceNo />
</LinerKit>
<PistonRings>
<Name>PKAR406963DB</Name>
<ReferenceNumber>
<Name1>K-40659600</Name1>
<Name2>N-8742560000</Name2>
</ReferenceNumber>
</PistonRings>
<PistonSet>
<Name>PTAR406963DB</Name>
<ReferenceNo />
<Description>
<Name1>alfin and with oil gallery</Name1>
<Name2>skirt MOS2 treated fits tapered con. rod</Name2>
</Description>
<Piston>
<Length>62.5</Length>
<Comp>40.5</Comp>
<Height1>-6</Height1>
<Height2>-12.3</Height2>
</Piston>
<Pin>
<Diameter>23.0</Diameter>
<Length>57.0</Length>
</Pin>
</PistonSet>
<RingsSet>
<Name>PRAR406961D</Name>
<ReferenceNo>
<Name1>A-R66830</Name1>
<Name2>G-0813760000</Name2>
<Name3>K-800056240000</Name3>
<Name4>M-01004N0</Name4>
</ReferenceNo>
<Description />
<Rings>
<Top>2.0</Top>
<2nd>1.5</2nd>
<Oil>2.0</Oil>
</Rings>
</RingsSet>
<CylLiner>
<Name></Name>
<ReferenceNo />
<Description />
<LinerSleeve>
<Lenght />
<OutsideDiameter />
<FlangeDiameter />
<FlangeDepth />
</LinerSleeve>
</CylLiner>
</EnginePart1>
</Catalog>
您的问题是第 54 行的 <2nd>
标签。 标签名称不能以数字开头。
下面是一个方便的工具,用于识别 XML 中问题的根源:http://www.w3schools.com/xml/xml_validator.asp
为了将来参考,XML 元素必须遵循以下命名规则:
- 名称可以包含字母、数字和其他字符
- 名称不能以数字或标点字符开头
- 名称不能以字母 xml 开头(或 XML,或 XML 等)
- 名称不能包含空格