0

I want to format a xml-string like it's done in notepad++.

The problem when using FormatXMLData ( the solution provided https://stackoverflow.com/a/235901/3135176 ) I get a parse error on the namespaceprefixes.

sample xml string :

<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

Community
  • 1
  • 1

1 Answers1

4

Your sample string does not declare the namespaces you are using, so you get the parsing error.

FormatXMLDoc is for formatting documents, not snippets.

Put a breakpoint on FormatXMLDoc() and step into it (compile with debug DCUs). 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.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Brandon Staggs
  • 630
  • 5
  • 16