我需要解码包含Base64-Binary-Data的XML-Container。 以下代码只是整个文档的一点点安静,但我认为您可以看到格式/架构。我不知道如何处理和base64_decode不会成为解决方案(?)
<container>
<header>
<Identifier>
<publicationId>2261000</publicationId>
</Identifier>
<ns2:Timestamp ns2:Id="body">
<ns2:Created>2014-06-06T16:00:03.177Z</ns2:Created></ns2:Timestamp>
</header>
<body>
<binary type="base64BinaryDatex2" id="B1">H4sIAAAAAAAAAOzdy5IbR5Yu6vl5ClgNdg+OOeT3i7Za23AlVSQlGckuHquZR4RHIoxIgBYASi3O
ymyfNzjz/RY1qlHpxU5EklIlkQSECAUifwLe1l1NMe9/ZkZ9Wu5rrW/+13/fLgd/C+WmWK/+8z/Y
kP7HIKzSdVasbv7zP/7r9ZzY//hf3/5f32T8+fqmSP3yxToLy0H1RqvNf/5psd2++/qrr263m7ff
rfJ1eeu31bv5apMuwq3/ijJCafW/f/rw6l//96b47U1++umn4U9iuC5vvuKUsq/+nxfPX929FSlW
m61fpaF6q03x9Yd39Xyd3r3nUz/i4MewLdfLV9u7l/64S5bFh3cw/O9N9qfBbf01jP0m/OXj1/0n
/qdB+O9tWNX/9L2/Df/5p0Pv4d4r/vbWv32h337zzv+8XPvs3hvcfRnbn98dfZ9LX8X9p6z6oovs
P//0hHDKJBFGqPpd/vsVJ2Xw23X57Tfperfalj9/m4Vvvvr1z9+s7l7HL7/Lwmpb5EUov53OyIvp
CzLerbKwqb7LiV9lg3kZqpcNXvvV2802LJdhNQjDwV+G33z1mffwzVef+/g3YRXKIr33NdSpfXvo
<!-- .... -->
答案 0 :(得分:0)
在使用base64_decode之前,您需要从XML中提取base64编码的字符串:
// Load XML from $xml variable
$doc = new DOMDocument();
$doc->loadXML($xml);
// Now pull out <binary> elements with XPath
$xpath = new DOMXPath($doc);
$list = $xpath->query("//binary");
// Now go through each base64 string and decode
$decoded = array();
foreach ($list as $binary)
{
$decoded[] = base64_decode($binary->nodeValue);
}
Array $ decoding将包含文档中所有已解码的二进制字符串