ÓÃc¶ÁÈ¡XMLÎļþ
¡¡ ¿ÉÒÔ½«XMLÎļþµÄÊ÷(Ö»ÓÐÒ»¸ö¶¥²ã½Úµã).ÓÚÊÇÀíËùµ±È»µÄ¿ÉÒÔÓÃÊ÷×÷ΪXMLµÄÒ»ÖÖ´æ´¢½á¹¹.
ÎÒ½«ÔÚÕâÀïÓÃC++ʵÏÖ¶Ô¼òµ¥µÄXMLÎļþµÄ½âÎö.
1.Ñ¡Ôñ´æ´¢½á¹¹:
Ê÷ÐÍÊý¾Ý½á¹¹ÓжàÖÖ´æ´¢·½Ê½,ÎÒ½«ÓÃ"º¢×ÓÐֵܱíʾ·¨",¶¨ÒåÈçÏÂ:
typedef struct CSNode
{
int subNodes;
string data;
string name;
struct CSNode *firstChild,*nextsibling,*parent;
CSNode* operator=(CSNode cnode)
{
this->data = cnode.data;
this->firstChild = cnode.firstChild;
this->name = cnode.name;
this->nextsibling = cnode.nextsibling;
this->subNodes = cnode.subNodes;
return this;
}
}CSNode,*CSTree;
2.¶¨ÒåÒ»¸öADT,Ìṩ²Ù×÷µÄ¹«¹²½Ó¿Ú.È¡ÃûΪ xml
class xml
{
public:
xml();
xml(char *fileName);
~xml();
CSNode& CreateTree(); // ½¨Á¢´æ´¢½á¹¹
bool findData(const char *nodepos); // ²éÕÒ½ÚµãÖµ
bool findData(const char *partent, const char *child,string *data); // ²éÕÒ½ÚµãÖµ
bool readfile_(); // ¶ÁÈ¡xmlÔ´Îļþ
void allocate(); // ÊͷŽڵã×ÊÔ´
private:
string _fileCope;
char* _filename;
CSNode *head;
};
3.¾ßÌåʵÏÖ
#include "stdafx.h"
#include "xmlCreate.h"
#include "wstack.h"
#include <algorithm>
using namespace std;
xml::xml()
{
}
xml::xml(char *fileName) : _filename(fileName)
{
head = new CSNode;
}
xml::~xml()
{
delete head;
}
CSNode& xml::CreateTree()
{
CSNode *p = new CSNode;
CSNode *q = new CSNode;
CSNode *s = new CSNode;
wstack<string> nameStack;
wstack<CSNode> nodeStack;
string tmpstr;
string name,tempname,rootName,headName;
int noods = 0;
bool subroot = true,next = false,poproot = false;
unsigned short int enoods = 0;
char ps;
for (size_t i = 0; i < _fileCope.size(); ++i){
ps = _fileCope[i];
if (_fileCope[i] == ' ' || _fileCope[i] == '' || _fileCope[i] == '\t' || _fileCope[i] == 0x09 || _fileCope[i] == 0x0d)continue;
if (_fileCope[i] == '<' && _fileCope[i+1] != '/') {
s = new CSNode;
s->subNodes = 0;
enoods = 0;
}
else if (_fileCope[i] == '>') {
enoods = 0;
s->name = tmpstr;
nameStack.push(
Ïà¹ØÎĵµ£º
ת×Ô£ºhttp://www.bmrtech.com/article/2008/081126.htm
ûÈËÄÜ·ñÈÏǶÈëʽӦÓÃÕý±äµÃÔ½À´Ô½Æձ顣µ«ÊÇ£¬µ±ÏµÍ³Ô½À´Ô½¸´ÔÓ£¬¶øÎÒÃǸ³ÓèϵͳԽÀ´Ô½¶àµÄÔðÈεÄʱºò£¬ÎÒÃǽ«±ØÐëÃæ¶ÔһЩÖØÒªÎÊÌâ¡£ÆäÖÐ×îÖØÒªµÄÎÊÌâÊÇ£ºÎÒÃÇÈçºÎ²ÅÄÜÈ·±£Ç¶ÈëʽϵͳÊÇ°²È«¿É¿¿µÄ£¿
C ±à³ÌÓïÑÔΪÓû§ÌṩÁËÐí¶àÇ¿´óµÄ¹¦ÄÜ£¬¼ ......
/*
coder: ACboy
date: 2010-3-14
result: 1A
description: UVa 327 Evaluating Simple C Expressions
*/
#include <iostream>
#include <algorithm>
using namespace std;
struct Node {
char name;
int value;
int lastValue;
int pos;
};
int cmp(const Node & a, const Node &a ......
XMLµÄÈ«³ÆExtensible Markup Language,Òâ˼ÊÇ¿ÉÀ©Õ¹µÄ±ê¼ÇÓïÑÔ£¬ÊDZê׼ͨÓñê¼ÇÓïÑÔSGML(Standard Generalized Markup Language)µÄÒ»¸ö×Ó¼¯¡£1998Äê2Ô£¬W3C·¢²¼ÁËXML1.0±ê×¼£¬ÆäÄ¿µÄÊÇΪÁËÔÚWebÉÏÄÜÒÔÏÖÓеij¬Îı¾±ê¼ÇÓïÑÔHTMLµÄʹÓ÷½Ê½Ìṩ£¬½ÓÊպʹ¦ÀíͨÓõÄSGML¡£XMLÊÇSGMLµÄÒ»¸ö¼ò»¯×Ó¼¯£¬ËüÒÔÒ»ÖÖ¿ª·ÅµÄ£¬×ÔÎÒÃèÊöµÄ ......
xhtmlµÄê¼»¨Ò»ÏÖ´øÀ´²»ÉÙÎÊÌ⣬ËüµÄÄ¿µÄÊÇÈÃhtml±íÏֵøüÏñxml£¬ËùÒԲŽÐxhtml¡£µ«Êdzöʦδ½ÝÉíÏÈËÀ£¬ÎÒÃÇÌÖÂÛÒ»ÏÂÈçºÎÅж¨ÎĵµÊÇXML°É¡£
Ó¡ÏóÖÐjQuery¶Ô´Ë·½·¨Öظ´ÊµÏÖÁËÐí¶à´Î£¬Ó¦¸Ã±È½ÏȨÍþ£¬Ò²ËµÃ÷ÕâÅж¨±È½ÏÄѸ㡣¿´jQuery1.42µÄʵÏÖ£º
var isXML = function(elem){
// documentElement is verifi ......
CµÄ±ä²ÎÎÊÌâÓëprintº¯ÊýµÄʵÏÖ
ÎÒÃÇÔÚCÓïÑÔ±à³ÌÖлáÓöµ½Ò»Ð©²ÎÊý¸öÊý¿É±äµÄº¯Êý,ÀýÈçprintf() Õâ¸öº¯Êý,ËüµÄ¶¨ÒåÊÇÕâÑùµÄ: int printf( const char* format, ...);
Ëü³ýÁËÓÐÒ»¸ö²ÎÊýformat¹Ì¶¨ÒÔÍâ,ºóÃæ¸úµÄ²ÎÊýµÄ¸öÊýºÍÀàÐÍÊǿɱäµÄ,ÀýÈçÎÒÃÇ¿ÉÒÔÓÐÒÔϲ»Í¬µÄµ÷Ó÷½·¨:
printf("%d",i);
&nb ......