libxml_set_streams_context
Description
The libxml_set_streams_context of libxml for PHP sets the streams context for the next libxml document load or write.
Syntax
libxml_set_streams_context(
resource $context
): voidParameters
context
The stream context resource (created with stream_context_create())
Return
No value is returned.
Examples
1 · context
<?
$options =
[
"http" =>
[
"method" => "POST"
]
];
$context = stream_context_create($options);
libxml_set_streams_context($context);
2 · DOMDocument
<?
$options =
[
"http" =>
[
"method" => "POST"
]
];
$context = stream_context_create($options);
libxml_set_streams_context($context);
$filename = $_SERVER["DOCUMENT_ROOT"] . "/assets/xml/namespace.xml";
$dom = new DOMDocument;
$dom->load($filename);
echo $dom->saveXML();
<?xml version="1.0"?>
<people>
<person xmlns:a="https://osbo.com">
<a:first a:class="myclass" a:id="myid" a:title="mytitle">first</a:first>
<a:last>last</a:last>
<a:age>age</a:age>
</person>
<person xmlns:b="https://osbo.com">
<b:first b:class="myclass" b:id="myid" b:title="mytitle">first</b:first>
<b:last>last</b:last>
<b:age>age</b:age>
</person>
<person xmlns:c="https://osbo.com">
<c:first c:class="myclass" c:id="myid" c:title="mytitle">first</c:first>
<c:last>last</c:last>
<c:age>age</c:age>
</person>
</people>