Last active
December 22, 2017 09:36
-
-
Save lloc/4525307 to your computer and use it in GitHub Desktop.
Code for http://lloc.it/xml-json-e-rdf.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'http://ws.geonames.org/search?q=london&maxRows=10&username=USERNAME'; | |
$xml = simplexml_load_file( $url ); | |
echo "Ausgabe des SimpleXML-Objects:\n"; | |
print_r( $xml ); | |
$json = file_get_contents( $url . '&type=json' ); | |
$arr = json_decode( $json ); | |
echo "Ausgabe der JSON-Daten als Array:\n"; | |
print_r( $arr ); | |
/** | |
* https://github.com/semsol/arc2.git | |
*/ | |
include_once 'arc2/ARC2.php'; | |
$parser = ARC2::getRDFParser(); | |
$parser->parse( $url . '&type=rdf' ); | |
$triples = $parser->getTriples(); | |
echo "Ausgabe der RDF-Daten als Array:\n"; | |
print_r( $triples ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment