2 require_once('../wp-load.php');
4 // columns we wish to find are: link_url, link_name, link_target, link_description
5 // we need to map XML attribute names to our columns
6 $opml_map = array('URL' => 'link_url',
7 'HTMLURL' => 'link_url',
9 'TITLE' => 'link_name',
10 'TARGET' => 'link_target',
11 'DESCRIPTION' => 'link_description',
12 'XMLURL' => 'link_rss'
19 ** Callback function. Called at the start of a new xml tag.
21 function startElement($parser, $tagName, $attrs) {
22 global $updated_timestamp, $all_links, $map;
23 global $names, $urls, $targets, $descriptions, $feeds;
25 if ($tagName == 'OUTLINE') {
26 foreach (array_keys($map) as $key) {
27 if (isset($attrs[$key])) {
28 $$map[$key] = $attrs[$key];
32 //echo("got data: link_url = [$link_url], link_name = [$link_name], link_target = [$link_target], link_description = [$link_description]<br />\n");
34 // save the data away.
35 $names[] = $link_name;
37 $targets[] = $link_target;
39 $descriptions[] = $link_description;
45 ** Callback function. Called at the end of an xml tag.
47 function endElement($parser, $tagName) {
51 // Create an XML parser
52 $xml_parser = xml_parser_create();
54 // Set the functions to handle opening and closing tags
55 xml_set_element_handler($xml_parser, "startElement", "endElement");
57 if (!xml_parse($xml_parser, $opml, true)) {
58 echo(sprintf(__('XML error: %1$s at line %2$s'),
59 xml_error_string(xml_get_error_code($xml_parser)),
60 xml_get_current_line_number($xml_parser)));
63 // Free up memory used by the XML parser
64 xml_parser_free($xml_parser);