Ò»¸ö¼òµ¥µÄxmlÀ࣬¿ÉÒÔ½âÎöºÍÉú³ÉxmlÎļþÊý¾Ý
<?php
include('xml.php');
$data = XML_unserialize($xml);
?>
$xml¼´ÊÇxmlÎļþµÄÄÚÈÝ£¬$dataÊǽâÎö³öµÄÊý×飻
<?php
include('xml.php');
$xml = XML_serialize($data);
?>
ÒÔÉÏΪʹÓÃʵÀý£¬·Ö±ð½âÎöxmlÎĵµºÍÉú³Éxml¸ñʽµÄÊý¾Ý
xml.phpÔ´Âë
<?php
###################################################################################
#
# XML Library, by Keith Devens, version 1.2b
# http://keithdevens.com/software/phpxml
#
# This code is Open Source, released under terms similar to the Artistic License.
# Read the license at http://keithdevens.com/software/license
#
###################################################################################
###################################################################################
# XML_unserialize: takes raw XML as a parameter (a string)
# and returns an equivalent PHP data structure
###################################################################################
function & XML_unserialize(&$xml){
$xml_parser = &new XML();
$data = &$xml_parser->parse($xml);
$xml_parser->destruct();
return $data;
}
###################################################################################
# XML_serialize: serializes any PHP data structure into XML
# Takes one parameter: the data to serialize. Must be an array.
###################################################################################
function & XML_serialize(&$data, $level = 0, $prior_key = NULL){
if($level == 0){ ob_start(); echo '<?xml version="1.0" ?>',"\n"; }
while(list($key, $value) = each($data))
if(!strpos($key, ' attr')) #if it's not an attribute
#we don't treat attributes by themselves, so for an empty element
# that has attributes you still need to set the element to NULL
if(is_array($value) and array_key_exists(0, $value)){
XML_serialize($value, $level, $key);
}else{
$tag = $prior_key ? $prior_key : $key;
echo str_repeat("\t", $level),'
Ïà¹ØÎĵµ£º
¡¡ ¿ÉÒÔ½«XMLÎļþµÄÊ÷(Ö»ÓÐÒ»¸ö¶¥²ã½Úµã).ÓÚÊÇÀíËùµ±È»µÄ¿ÉÒÔÓÃÊ÷×÷ΪXMLµÄÒ»ÖÖ´æ´¢½á¹¹.
ÎÒ½«ÔÚÕâÀïÓÃC++ʵÏÖ¶Ô¼òµ¥µÄXMLÎļþµÄ½âÎö.
1.Ñ¡Ôñ´æ´¢½á¹¹:
Ê÷ÐÍÊý¾Ý½á¹¹ÓжàÖÖ´æ´¢·½Ê½,ÎÒ½«ÓÃ"º¢×ÓÐֵܱíʾ·¨",¶¨ÒåÈçÏÂ:
typedef struct CSNode
{
int subNodes;
string data;
string name;
struct CSNode *fi ......
¶ÔÓÚ½«TXTÎĵµÖÐÊý¾Ýµ¼ÈëXMLÖеijÌÐòÍøÉϲ»¶à£¬µ«ÊÇÓкܶàÊÇÏȽ«TXTµ¼Èëµ½DataSetÖУ¬ÔÚÓÃXML½øÐд«Êä¡£ËùÒÔ±¾È˾ÍÔÚÕâÀïÓë´ó¼Ò·ÖÏíÒ»ÏÂÖ±½Óµ¼ÈëµÄÕâÖÖ·½Ê½¡£
±¾³ÌÐòÒ²¿ÉÒÔÓ¦ÓÃÓÚASP.NETÖУ¬ÄÇôÏÂÃæµÄÃüÃû¿Õ¼ä¼°Ò»Ð©µØ·½¾ÍµÃ¸Ä¸ÄÁË£¬»¹ÓÐÒª½«³ÌÐò¶¼·ÅÓÚPage_LoadÖС£
using System;
using System.Collections.Generic;
......
ÔÚ×î½üµÄÏîÄ¿ÖУ¬Å¼Óöµ½Ò»¸ö¿ÉÒÔ˵ºÜСµÄÎÊÌ⣬¾²ÏÂÐÄÀ´£¬ÓÐÏë°ÑËü¼ÇÏÂÀ´µÄ³å¶¯£¬Ëæ²úÉúÕâ²»³ÉÎĵļ¸¶ÎÎÄ×Ö¡£
ÔÚÎÒÓÃReadXml£¨£©ºÍReadSchema£¨£©¶ÁÈ¡XMLÎļþʱ£¬×ÜÊdzöÏÖÒì³££¬ºóÀ´¾¹ýµ÷ÊÔ·¢ÏÖ±¨XmlExceptionÒì³£²¢Ìáʾ“ȱÉÙ¸ùÔªËØ&rd ......
xmlÓÐʲôÓÅÊƺÍÌصã
“¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ”(XML) ÌṩһÖÖÃèÊö½á¹¹»¯Êý¾ÝµÄ·½·¨¡£ÓëÖ÷ÒªÓÃÓÚ¿ØÖÆÊý¾ÝµÄÏÔʾºÍÍâ¹ÛµÄ
HTML ±ê¼Ç²»Í¬£¬XML ±ê¼ÇÓÃÓÚ¶¨ÒåÊý¾Ý±¾ÉíµÄ½á¹¹ºÍÊý¾ÝÀàÐÍ¡£
XML
ʹÓÃÒ»×é±ê¼ÇÀ´Ãè»æÊý¾ÝÔªËØ¡£Ã¿¸öÔªËØ·â×°¿ÉÄÜÊ®·Ö¼òµ¥Ò²¿ÉÄÜÊ®·Ö¸´ÔÓµÄÊý¾Ý¡£Äú¿ÉÒÔ¶¨ÒåÒ»×éÎÞÏÞÖÆµÄ XML ±ê¼Ç¡£ÀýÈç£ ......