|
|
|
<?php
////////////////////////////////////////////////////////////////////////
//Variables to be set
$coord_sys = "LL";
$datum = "WGS-84";
$format = "IDMS0";
$max_del = 30;
$msisdns = array();
////////////////////////////////////////////////////////////////////////
error_reporting(E_ALL);
//if (!$docnode = domxml_open_mem($theXML))
//echo "SOME ERROR";
//create a DOMXML object by reading the XML data from a file, the two lines above
can be
uncommented to
//create an object by reading it from a string
if (!$docnode = domxml_open_file("http://localhost/post/bot/xml/request.xml"))
echo "SOME ERROR";
//$docnode = create_text_node($theXML);
//get the root element of the document
$root = $docnode->document_element();
echo "ROOT: " . $root->node_name(); //display it (just in case)
if(!$childs = $root->child_nodes()) //creating a list of child nodes of the root,
should be an
array
echo "no child nodes<br>";
if (is_array($childs)) //just to check if what we got above really IS an array
(delete it if you are
sure that everything's working)
echo "\nARRAY\n";
else
echo "\nNONE\n";
while ($node = array_shift($childs)) //traversing the array of child-nodes of the
root
{
if (strcasecmp($node->node_name(), "client") == 0) //the second level of
hierarchy (refer
to the request.xml file for explanations)
{
if (!$client_children = $node->child_nodes())
echo "Error getting childer of client";
while ($extra_node = array_shift($client_children)) //here we only
output the data
about the child nodes, all the necessary data is contained in the children of the
next node
{
if (substr_count($extra_node->node_name(), "#") < 1)
echo "Client_content: " . $extra_node->node_name() . "
content: " .
$extra_node->get_content() . "\n";
}
}
if (strcasecmp($node->node_name(), "lir") == 0) //the node that contains the
necessary
information
{
if (!$client_children = $node->child_nodes()) //creating an array with
all the children
of it
echo "Error getting childer of client";
while ($extra_node = array_shift($client_children)) //traversing the
list of children
of "<LIR>"
{
$sh = 0;
//retrieving information from the GEO_INFO node
if (strcasecmp($extra_node->node_name(), "geo_info") == 0)
{
if (!$client_children_extra = $extra_node->child_nodes())
echo "Error getting childer of geo_info";
while ($array_node = array_shift($client_children_extra))
{
if (substr_count($array_node->node_name(), "#") < 1)
{
//the following set of IF's checks whether we
are looking at the node
the content of which corresponds to one of teh variables we want to set, and if so,
we set it
if (strcasecmp($array_node->node_name
(), "coord_sys") == 0)
$coord_sys = $array_node->get_content();
else if (strcasecmp($array_node->node_name
(), "datum") == 0)
$datum = $array_node->get_content();
else if (strcasecmp($array_node->node_name
(), "format") == 0)
$format = $array_node->get_content();
echo $array_node->node_name() . " content
(geo_info): " .
$array_node->get_content() . "\n";
}
}
}
//retieving data from MSISDN node
else if (strcasecmp($extra_node->node_name(), "msids") == 0)
{
if (!$client_children_extra = $extra_node->child_nodes())
echo "Error getting childer of client";
while ($array_node = array_shift($client_children_extra))
{
if (substr_count($array_node->node_name(), "#") < 1)
{
if (strcasecmp($array_node->node_name
(), "msid") == 0) //in this
case we should add a number to the msisdns array
{
$msisdns[$sh] = $array_node->get_content();
$sh++;
}
echo $array_node->node_name() . " content
(msids): " . $array_node-
>get_content() . "\n";
}
}
}
//retieving data from QoS node
else if (strcasecmp($extra_node->node_name(), "qos") == 0)
{
if (!$client_children_extra = $extra_node->child_nodes())
echo "Error getting childer of client";
while ($array_node = array_shift($client_children_extra))
{
if (substr_count($array_node->node_name(), "#") < 1)
{
echo $array_node->node_name() . " content
(qos): " . $array_node-
>get_content() . "\n";
if (strcasecmp($array_node->node_name
(), "qos") == 0)
$max_del = intval($array_node->get_content
());
}
}
}
}
}
}
//once again displaying the data we got from the XML (this time we use the variables
that
have been initialized)
reset($msisdns);
echo "\nCoordinate system: " . $coord_sys;
echo "\nDatum: " . $datum;
echo "\nFormat of data: " . $format;
echo "\nMaximum delay: " . $max_del;
//traverse through the array we created above
while ($elem = array_shift($msisdns))
echo "\nMSISDN: $elem";
?> |
|
| RSS parser.
Parses RSS into an array. Quick and nasty but does the job.
No checking is done for correct Tags, only correct XML.
PHP4 needed to display result (uses print_r). Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS) | | | A very basic and fast XML parser Categories : PHP, PHP Classes, XML | | | Simple newsreader script Categories : PHP, XML, Rich Site Summary (RSS) | | | RSS parser using PHP5 and simpleXML Categories : Rich Site Summary (RSS), PHP, XML | | | Glossword - glossary compiler Categories : Content Management, PHP, MySQL, XML | | | Amazon.com API, CURL-REST Parser. Obtain data about Amazon products (PHP5 +) Categories : PHP, Ecommerce, XML, Web Services, CURL | | | XML easy parser Categories : PHP, XML | | | MySQL or SQL Query to XML Output Categories : PHP, MySQL, XML, Databases | | | XML Menu Categories : PHP, PHP Classes, Navigation, XML, XSL | | | Directory Listing To XML : Outputs XML File of a Given Directory Listing Categories : PHP, PHP Classes, XML, Directories | | | Trivia Quiz program using XML, XSLT and PHP Categories : PHP, XML, XSLT | | | Dynamic Loading of XML array data into ComboBox and Display XML data using PHP + DOM + Javascript. Categories : PHP, Java Script, DOM XML, XML, Arrays | | | SAPIPROCESSOR - is a compact XML-based CMS toolkit Categories : PHP, Content Management, XML | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | On-the-fly drop down menu from a txt or xml file Categories : PHP, XML, HTML and PHP | |
|
|
|