php - 原始 PDF 的响应无法解析为 XML
问题描述
我从一个看起来像这样的 API 收到 XML 响应;
<?xml version="1.0" encoding="ISO-8859-1"?>
<tppxmlresponse>
<requestvalid>1</requestvalid>
<invoicevalid>1</invoicevalid>
<invoicepdf><![CDATA[%PDF-1.3
%“Œ‹ž ReportLab Generated PDF document http://www.reportlab.com
% 'BasicFonts': class PDFDictionary
1 0 obj
% The standard fonts dictionary
<< /F1 2 0 R
/F2 3 0 R
/F3+0 11 0 R >>
endobj
(....)
startxref
110364
%%EOF
]]></invoicepdf></tppxmlresponse>
<invoicepdf>
包含我要获取的原始 PDF。但是在响应上使用常规new SimpleXMLElement($response);
会返回以下错误;
PHP Fatal error: Uncaught Exception: String could not be parsed as XML in (...)
任何能够最好地访问 .xml 内容<invoicepdf>
、剥离 XML 的想法都会很棒。谢谢!
解决方案
推荐阅读
- javascript - 扫雷中的逻辑问题
- java - 如何通过 livy Programmatic API 提交批处理 jar Spark 作业
- android - 在 Android 中反应原生多包
- spring-boot - 如何将应用引擎存储桶的 url 添加到数据库 java
- statistics - 卡方检验在这里正确吗?
- reactjs - 如何在 redux 的 DISpatch 中使用回调?
- javascript - 使用较短的数据库查询代码将数据插入 MySQL 数据库表
- javascript - 设置计算样式(无法在“CSSStyleDeclaration”上执行“setProperty”:这些样式已计算)
- javascript - 使用 JavaScript 验证输入 HTML
- javascript - 无法使用 javascript 在标签内将值递增一