ANS-1334 · SUITESCRIPT DEVELOPMENT
How to Resolve XML Parsing Errors with nlapiXMLToPDF in NetSuite
NetSuite's nlapiXMLToPDF function can fail due to malformed XML, often caused by invalid HTML tags, unclosed elements, or non-standard characters in source data.
Short answer
XML parsing errors with nlapiXMLToPDF typically stem from invalid characters like smart quotes or unsupported bullet points, unclosed HTML/XML tags (e.g., <br> instead of <br/>), or incorrect tag usage (e.g., <il> instead of <li>). Ensure all XML elements are properly closed and use standard HTML/XML syntax.
Scenario
Users attempting to generate PDF documents using NetSuite's nlapiXMLToPDF function may encounter parsing errors. This often occurs when the XML source data contains non-standard characters, malformed HTML, or unclosed XML elements, preventing the function from correctly processing the input.
Solution
The nlapiXMLToPDF function is sensitive to the exact formatting and content of the XML input. Common causes of parsing errors and their resolutions include:nnUnsupported Characters
The presence of certain characters, such as specific types of bullet points or "smart" quotation marks (e.g., ‘ and ’ instead of ', or “ and ” instead of ") can lead to parsing failures. These should be replaced with standard equivalents.nnUnclosed XML Elements
Unlike HTML, XML requires all elements to be explicitly closed. Thus, to skip a line, the self-closing tag must be used, not .nnInvalid HTML Tags
Incorrect or non-standard HTML tags in the text can cause errors. For example, ` and were used instead of
and Expert NetSuite Support
Need help with this NetSuite issue?
SuiteScript Development consulting and configuration support
