faqts : Computers : Programming : Languages : PHP : Function Libraries : XML

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 10 people (10%) answered Yes
Recently 0 of 9 people (0%) answered Yes

Entry

How can I parse a xml source from a string (not from a file) ?

Dec 23rd, 2001 12:10
Alexandr Kalendarev, Gary Chen,


You can to use SAX model
function startElement($parser, $name, $attrs) {
// parse code
}
}
function endElement($parser, $name) {
//  parse code
}
$data=" <data><...>...</data>"
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_parse($xml_parser, $data );
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
xml_parser_free($xml_parser);