简体   繁体   English

格式XML字符串-EDOMParseError

[英]Format XML String - EDOMParseError

I want to format a xml-string like it's done in notepad++. 我想格式化xml字符串,就像在notepad ++中一样。

The problem when using FormatXMLData ( the solution provided https://stackoverflow.com/a/235901/3135176 ) I get a parse error on the namespaceprefixes. 使用FormatXMLData时的问题(该解决方案提供了https://stackoverflow.com/a/235901/3135176 )我在名称空间前缀上遇到了解析错误。

sample xml string : 样本xml字符串:

<ns1:Make><ns1:CustomerID>K||15538</ns1:CustomerID></ns1:Make>

result in notepad++ : 导致记事本++:

<ns1:Make>
    <ns1:CustomerID>K||15538</ns1:CustomerID>
</ns1:Make>

Please advice 请指教

Your sample string does not declare the namespaces you are using, so you get the parsing error. 您的示例字符串未声明您正在使用的名称空间,因此您会收到解析错误。

FormatXMLDoc is for formatting documents, not snippets. FormatXMLDoc用于格式化文档,而不是摘要。

Put a breakpoint on FormatXMLDoc() and step into it (compile with debug DCUs). FormatXMLDoc()上放置一个断点, FormatXMLDoc()断点(使用调试DCU进行编译)。 You will see that the first thing it does is create a document from your string. 您将看到,它所做的第一件事就是根据您的字符串创建文档。 So it needs to be a complete and valid document. 因此,它需要是完整且有效的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM