I need to decode a XML-Container which contains Base64-Binary-Data. The following code is just a little peace of the whole document but I think that you can see the format/schema. I don't know how to handle and base64_decode won't be the solution(?)
<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
<!-- .... -->
Before you can use base64_decode you need to pull out base64 encoded string out of XML:
// 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 $decoded will contain all decoded binary strings from your document
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.