Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

phpÏÂÄÄÖÖ·½·¨ºÏÊʽâÎöxml£¬×ª»»³Éjson¸ñʽ

½âÎöxmlÎĵµµÄÀà¿âÓкܶàÖÖ£¬±È½Ï³£ÓõľÍÊÇSimpleXML£¬DOM Document£¬XMLReader£¬»ùÓÚSAXµÄxml_parseº¯Êý¡£
¸ù¾ÝxmlÎĵµ½á¹¹£¬ÒÔ¼°ÐèÇóµÄ²»Í¬£¬ÒªÑ¡ÔñºÃ¶ÔÓ¦µÄÀà¿â¡£
½âÎöСµÄÎĵµµÄ»°£¬Ê¹ÓÃSimpleXML±È½ÏºÏÊÊ£¬¼òµ¥µÄ¼¸¸öº¯Êý¾Í¿ÉÒԸ㶨¡£
Èç¹ûÎĵµ·Ç³£¾Þ´ó£¬×îºÃÊÇXMLReader´ò¿ª£¬Öмäת»»³ÉDOMÀ´½âÎö£¬¸Ð¾õDOMÓëXPath½áºÏµÄ±È½ÏºÃ¡£
ÒÔÉÏÊǽâÎöÒÑÖªÎĵµ½á¹¹µÄXML£¬±ÈÈçÖªµÀʹÓÃÁËʲôÃüÃû¿Õ¼ä£¬ÓÐÄÄЩÖ÷ÒªµÄ½ÚµãµÈµÈÐÅÏ¢µÄXMLÎĵµ¡£
Èç¹ûÊÇÒª½âÎöÈÎÒâµÄXMLÎĵµ£¬»¹ÊÇSAXµÄxml_parse±È½ÏºÏÊÊ£¬×Ô¼º¶¨ÒåÈý¸öhandlerº¯Êý¡£
±ÈÈç±ÊÕß¾ÍÊÇÓÃxml_parseÀ´½âÎöÈÎÒâµÄxmlÎĵµ£¬Éú³Éjson¸ñʽµÄ×Ö·û´®¡£
ÏÂÃæ°ÑʹÓÃxml_parseÀ´½âÎöxmlÎĵµµÄËùÐèÒªµÄÈý¸öhandler½²½âÒ»±é¡£
Ê×ÏÈÊÇÈý¸ö±äÁ¿
$depthÊÇÖ¸xmlÎĵµ½á¹¹µÄ²ãÊý£¬µÚÒ»²ãµÄÖµÊÇ0¡£
$json_arrayÊÇÒ»¸ö¶àλÊý×飬ÿһ¸öÔªËصijÉÔ±ÊÇÒ»¸öjsonÊý×飬ֱ½Ó¿ÉÒÔÓÃjson_encodeº¯Êý¡£
Õâ¸öÊý×éµÄµÚһάµÄindexÊÇÉÏÃæµÄ$depth£¬½âÎöÍêÿһ²ãµÄxml½á¹¹ºó£¬¶¼½«Æä½á¹û"Õ³Ìù"µ½Æ丸½ÚµãµÄ×îºóÒ»¸ö×Ö½Úµãºó±ß¡£
½âÎöÍê³Éºó$json_array[0]¾ÍÊÇËùÓеÄxmlÎĵµÄÚÈݶ¼ÔÚÀïÃæÀ²¡£
$tag_name_stackÒ²ÊÇÒ»¸öÊý×飬ºó½øÏȳöµÄÊý×飬ÕýÔÚ´¦ÀíµÄ±êÇ©Ãû¾Í´æÔÚÕâÀïÃ棬´¦ÀíÍêÒ»¸ö±êÇ©ºó£¬¾Í½«ÆäÇë³öÊý×é¡£
private $depth = -1;
private $json_array = array();
private $tag_name_stack = array();
private function start_handler($parser, $name, $attrs) {
$arrts_array = array();
foreach ($attrs as $attr_name => $attr_value) {
$attr_name = str_replace(":", "$", $attr_name);
$arrts_array[$attr_name]=$attr_value;
}
$tag_name = str_replace(":", "$", $name);
$this->tag_name_stack[] = $tag_name;
$this->depth++;
//if (count($arrts_array) != 0) {
$this->json_array[$this->depth][$tag_name] = $arrts_array;<br>
Ê×ÏÈÊǰѸñêÇ©µÄÊôÐÔ¶¼×°ÈëÒ»¸öÊý×é
foreach ($attrs as $attr_name => $attr_value) {
      $attr_name = str_replace(":", "$", $attr_nam


Ïà¹ØÎĵµ£º

.net ²Ù×÷XMLС½á

Ò»¡¢¼òµ¥½éÉÜ
using System.Xml;
//³õʼ»¯Ò»¸öxmlʵÀý
XmlDocument xml=new XmlDocument();
//µ¼ÈëÖ¸¶¨xmlÎļþ
xml.Load(path);
xml.Load(HttpContext.Current.Server.MapPath("~/file/bookstore.xml"));
//Ö¸¶¨Ò»¸ö½Úµã
XmlNode root=xml.SelectSingleNode("/root");
//»ñÈ¡½ÚµãÏÂËùÓÐÖ±½Ó×Ó½Úµã
XmlNodeList ch ......

PHP+DOM´´½¨XMLÎļþ

´´½¨ÎĵµÀàÐÍÉùÃ÷
Ò»°ã¶øÑÔ£¬XMLÉùÃ÷·ÅÔÚÎĵµ¶¥²¿¡£ÔÚPHPÖÐÉùÃ÷Ê®·Ö¼òµ¥£ºÖ»ÐèʵÀý»¯Ò»¸öDOMÎĵµÀàµÄ¶ÔÏ󲢸³ÓèËüÒ»¸ö°æ±¾ºÅ¡£²é¿´³ÌÐòÇåµ¥A£º
³ÌÐòÇåµ¥ A
<?php
// create doctype
$dom = new DOMDocument("1.0");
// display document in browser as plain text
// display document in browser as plain text ......

Ö§³Ö¼¸ºõËùÓÐä¯ÀÀÆ÷µÄjsÔØÈëxmlÎļþ

1.route.xmlÎļþÄÚÈÝ
<?xml version="1.0" encoding="GBK"?>
<root>
<route id="1111">
<id>111</id>
<name>ËÄ´¨</name>
<path>www.baidu.com/hehe.html</path>
</route>
</root>
2.test.html´úÂë
<html>
<body>
<script> ......

PHPͼ±íÖÆ×÷¹¤¾ß¼¯

ת×Ô£ºhttp://nedvedheqing.javaeye.com/blog/383506
1. PHPÀ©Õ¹
JpGraph£ºhttp://www.aditus.nu/jpgraph/
ChartDirector£ºhttp://www.advsofteng.com/
2. JavaScript
Flot (http://code.google.com/p/flot/
) - Flot Ϊ jQuery ÌṩµÄjavascript´úÂë¿â. ÈÝÒ×ʹÓã¬ÓÐÌØÉ«µÄͼ±í£¬Ìṩ½»»¥¹¦ÄÜ(Äܹ»·Å´óËõСÊý¾ÝÇøÓòµ ......

php while Óëdo whileµÄÇø±ð

±¾½Ì³ÌÀ´½²Ò»Ï¹ØÓÚÔÚphp±à³ÌÖг£Óõ½µÄÑ­»·Óï¾ädo whileÓëwhileµÄÇø±ð°É£¬while Êǵ±Ìõ¼þΪÕæÊDzÅÖ´Ðжødo whileÖÁÉÙ»áÖ´ÐÐһϣ¬ÏÂÃæÎÒÃǾÍÀ´¿´¿´
do {
}while(Ìõ¼þ)
¿´do whileµÄʵÀý°É¡£
<?
$a =10;
do {
echo $a;
}while ($a>11)
ÕâÀï»áÊä³ö10;È»ºóÑ­»·ÖÕÖ¹£¬ÄÇôÎÒÃÇÀ´¿´¿´whileµÄʵÀý°É¡£
$a=10;
w ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ