php xml³£Óú¯ÊýµÄ¼¯ºÏ(±È½ÏÏêϸ)

5年以前  |  阅读数:726 次  |  编程语言:PHP 

1¡¢DOM º¯Êý

a¡¢DOMDocument->load()
×÷Ó㺼ÓÔØxmlÎļþ
Ó裺DOMDocument->load( string filename )
²ÎÊý£ºfilename£¬xmlÎļþ£»
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø TRUE£¬Ê§°ÜÔoµ»Ø FALSE¡£

b¡¢DOMDocument->loadXML()
×÷Ó㺼ÓÔØxml´uÂe
Ó裺DOMDocument->loadXML( string source )
²ÎÊý£ºsource xml´uÂe£»
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø TRUE£¬Ê§°ÜÔoµ»Ø FALSE¡£

c¡¢DOMDocument->getElementsByTagName_r()
×÷Ó㺰´±eÇ(C)Ãu²eÕÒ
Ó裺DOMDocument->getElementsByTagName_r(string name)
²ÎÊý£ºname£¬±eÇ(C)Ãu³Æ£»
µ»Ø£ºÐ嵀 DOMNodeList ¶ÔÏo ¡£

d¡¢DOMDocument->getElementById()
×÷Ó㺰´±eÇ(C)Ãu²eÕÒ
Ó裺DOMDocument->getElementById(string elementId )
²ÎÊý£ºelementId £¬±eÇ(C)id£»
µ»Ø£ºÐ嵀 DOMNodeList ¶ÔÏo ¡£

e¡¢DOMDocument->createElement_x_x()
×÷Ó㺴´½¨±eÇ(C)
Ó裺DOMDocument->createElement_x_x(string name [, string value] )
²ÎÊý£ºname£¬±eÇ(C)Ãu³Æ£¬value£¬Ö»£»
µ»Ø£ºÐ嵀 DOMElement ¶ÔÏo£¬Ê§°ÜΪfalse ¡£

f¡¢DOMDocument->createTextNode()
×÷Ó㺴´½¨Îı¾½Úµa
Ó裺DOMDocument->createTextNode(string content )
²ÎÊý£ºcontent£¬ÄÚÈÝ£»
µ»Ø£ºÐ嵀 DOMText ¶ÔÏo£¬Ê§°ÜΪfalse ¡£

h¡¢DOMDocument->createCDATASection()
×÷Ó㺴´½¨cdata½Úµa
Ó裺DOMDocument->createCDATASection( string data )
²ÎÊý£ºdata£¬ÄÚÈÝ£»
µ»Ø£ºÐ嵀 DOMCDATASection ¶ÔÏo£¬Ê§°ÜΪfalse ¡£

i¡¢DOMDocument->createAttribute()
×÷Ó㺴´½¨±eÇ(C)ÊoÐÔ
Ó裺DOMDocument->createAttribute(string name)
²ÎÊý£ºname£¬ÊoÐÔÃu³Æ£»
µ»Ø£ºÐ嵀 DOMAttr ¶ÔÏo£¬Ê§°ÜΪfalse ¡£

j¡¢DOMDocument->validate()
×÷Ó㺼iÑexml´uÂe
Ó裺DOMDocument->validate()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø TRUE£¬Ê§°ÜÔoµ»Ø FALSE¡£

k¡¢DOMDocument->save()
×÷Ó㺱£´aexml´uÂeµ½xmlÎļþ
Ó裺DOMDocument->save(string filename )
²ÎÊý£ºfilename£¬xmlÎļþ£»
µ»Ø£º³É¹¦µ»Øxml×Öu³¤¶È£¬Ê§°Ü*µ»Øfalse¡£

l¡¢DOMDocument->saveXML()
×÷Ó㺱£´aexml´uÂe
Ó裺DOMDocument->saveXML( [DOMNode node [, int options]] )
²ÎÊý£ºnode£¬DOMNode£»
µ»Ø£º³É¹¦µ»Øxml£¬Ê§°Üµ»Øfalse¡£

m¡¢DOMElement->hasAttribute()
×÷Ó㺼i²aÊoÐÔÊÇñ´aeÔÚ
ÓÃ
¨£ºDOMElement->hasAttribute(string name)
²ÎÊý£ºname£¬ÊoÐÔÃu³Æ£»
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø TRUE£¬Ê§°ÜÔo*µ»Ø FALSE¡£

n¡¢DOMElement->getAttribute()
×÷Ó㺻ñÈ¡ÊoÐÔÖµ
Ó裺DOMElement->getAttribute(string name)
²ÎÊý£ºname£¬ÊoÐÔÃu³Æ£»
µ»Ø£º³É¹¦µ»ØÊoÐÔÖµ£¬Ê§°Üµ»Ø¿Õ¡£

o¡¢DOMElement->getAttribute()
×÷Ó㺻ñÈ¡ÊoÐÔÖµ
Ó裺DOMElement->getAttribute(string name)
²ÎÊý£ºname£¬ÊoÐÔÃu³Æ£»
µ»Ø£º³É¹¦µ»ØÊoÐÔÖµ£¬Ê§°Üµ»Ø¿Õ¡£

p¡¢DOMElement->setAttribute()
×÷ÓãºÉeÖÃÊoÐÔÖµ
Ó裺DOMElement->setAttribute(string name, string value )
²ÎÊý£ºname£¬ÊoÐÔÃu³Æ£»value£¬ÊoÐÔÖµ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø TRUE£¬Ê§°ÜÔoµ»Ø FALSE¡£

q¡¢DOMNode->appendChild()
×÷Ó㺽«×Ó½ÚµaÁ´½Óµ½¸¸½ÚµaÉÏ
Ó裺DOMNode->appendChild(DOMNode newnode )
²ÎÊý£ºnewnode£¬Ð½ڵa£»
µ»Ø£º³É¹¦µ»Øнڵa£¬Ê§°Üµ»Ø¿Õ¡£

r¡¢DOMNode->hasAttributes()
×÷Ó㺼iÑeÊÇñÓÐÊoÐÔ
ÓÃ
¨£ºDOMNode->hasAttributes( )
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø TRUE£¬Ê§°ÜÔo*µ»Ø FALSE¡£

s¡¢DOMNode->hasChildNodes()
×÷Ó㺼i²aÊÇñÓÐ×Ó½Úµa
ÓÃ
¨£ºDOMNode->hasChildNodes()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø TRUE£¬Ê§°ÜÔo*µ»Ø FALSE¡£

t¡¢DOMNode->insertBefore()
×÷Ó㺰Ñ×Ó½Úµa²aÈedomÊ÷,λÖÃÔÚij½ÚµaÇ°
Ó裺DOMNode->insertBefore(DOMNode newnode [, DOMNode refnode] )
²ÎÊý£ºnewnode£¬ÐÂnode£»refnode£¬²ÎÕÕnode
µ»Ø£º³É¹¦µ»ØÐÂnode£¬Ê§°Üµ»Ø¿Õ¡£

u¡¢DOMNode->removeChild()
×÷ÓãºÉ¾³ý×Ó½Úµa
Ó裺DOMNode->removeChild(DOMNode oldnode )
²ÎÊý£ºoldnode£¬×Ó½Úµa£»
µ»Ø£º³É¹¦µ»Ø×Ó½Úµa£¬Ê§°Üµ»Ø¿Õ¡£

v¡¢DOMNode->replaceChild()
×÷Ó㺸uÐÂ×Ó½Úµa
Ó裺DOMNode->replaceChild(DOMNode newnode, DOMNode oldnode )
²ÎÊý£ºnewnode£¬ÐÂnode£»oldnode£¬ÀϵÄnode
µ»Ø£º³É¹¦µ»Øoldnode£¬Ê§°Üµ»Ø¿Õ¡£

¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª-DOMNode ÊoÐÔ¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¨C

a¡¢DOMNode->nodeType
×÷Ó㺻ñÈ¡½ÚµaÀaÐÍ

b¡¢DOMNode->nodeName
×÷Ó㺻ñÈ¡½ÚµaÃu³Æ

c¡¢DOMNode->nodeValue
×÷Ó㺻ñÈ¡½ÚµaÄÚÈÝ

d¡¢DOMNode->textContent
×÷Ó㺻ñÈ¡½ÚµaÄÚÈÝ

e¡¢DOMNode->parentNode
×÷Ó㺻ñÈ¡½Úµa¸¸½Úµa

f¡¢DOMNode->childNodes
×÷Ó㺻ñÈ¡½Úµa×Ó½Úµa

g¡¢DOMNode->firstChild
×÷Ó㺻ñÈ¡½ÚµaµÚÒ»¸o×Ó½Úµa

h¡¢DOMNode->lastChild
×÷Ó㺻ñÈ¡½Úµa×iºoÒ»¸o×Ó½Úµa

2¡¢XMLReader

a¡¢XMLReader::XML
×÷ÓãºÔØÈe xml ×Öu´®
ÓÃ
¨£ºXMLReader::xml(string source [, string encoding [, int options]] )
²ÎÊý£ºsource£¬xml string£»encoding£¬document encoding or NULL
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø TRUE£¬Ê§°ÜÔo*µ»Ø FALSE¡£

b¡¢XMLReader::open
×÷ÓãºÔØÈexmlÎļþ
Ó裺XMLReader::open(string url [, string encoding [, int options]] )
²ÎÊý£ºurl£¬Á¬½Óµ½xmlµÄÁ´½Ó£»encoding£¬document encoding or NULL
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø TRUE£¬Ê§°ÜÔoµ»Ø FALSE¡£

c¡¢XMLReader::read
×÷Ó㺶ÁÈ¡ xml£¬Ê¹½aÎoÆ÷Ç°½øµ½ÏÂÒ»¸o±e¼Ç
Ó裺XMLReader::read()£¬ÔÚ while Ñ­»ÖбeÀuÕu¸oÎĵµ
²ÎÊý£ºNULL
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø TRUE£¬Ê§°ÜÔo*µ»Ø FALSE¡£

d¡¢XMLReader::getAttribute
×÷Ó㺻ñÈ¡ÊoÐÔ
Ó裺XMLReader::getAttribute(string name)
²ÎÊý£ºname£¬ÊoÐÔÃu³Æ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø ÊoÐÔÖµ£¬Ê§°ÜÔoµ»Ø FALSE¡£

e¡¢XMLReader::isValid
×÷Ó㺼iÑexmlÊÇñºÏ¨
Ó裺XMLReader::isValid()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

f¡¢XMLReader::moveToAttribute
×÷ÓãºÒƶ¯½¹µaµ½ËuÖ¸µÄÊoÐÔÉÏ
Ó裺XMLReader::moveToAttribute(string name)
²ÎÊý£ºname£¬ÊoÐÔÃu³Æ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

g¡¢XMLReader::moveToFirstAttribute
×÷ÓãºÒƶ¯½¹µaµ½µÚÒ»¸oÊoÐÔÉÏ
Ó裺XMLReader::moveToFirstAttribute()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

h¡¢XMLReader::moveToNextAttribute
×÷ÓãºÒƶ¯½¹µaµ½ÏÂÒ»¸oÊoÐÔÉÏ
Ó裺XMLReader::moveToNextAttribute()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

i¡¢XMLReader::moveToElement
×÷ÓãºÒƶ¯½¹µaµ½¸¸½Úµaµ±Ç°ÊoÐÔÉÏ
Ó裺XMLReader::moveToElement()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

j¡¢XMLReader::close
×÷Ó㺹رÕxmlÊaÈe
Ó裺XMLReader::close()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

¡ª¡ª¡ª¡ª¡ª¡ª¡ª-³£Á¿¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¨C

XMLReader::NONE = 0 ;
XMLReader::ELEMENT = 1 ;
XMLReader::ATTRIBUTE = 2 ;
XMLReader::TEXT = 3 ;
XMLReader::CDATA = 4 ;
XMLReader::ENTITY_REF = 5 ;
XMLReader::ENTITY = 6 ;
XMLReader::PI = 7 ;
XMLReader::COMMENT = 8 ;
XMLReader::DOC = 9 ;
XMLReader::DOC_TYPE = 10 ;
XMLReader::DOC_FRAGMENT = 11 ;
XMLReader::NOTATION = 12 ;
XMLReader::WHITESPACE = 13 ;
XMLReader::SIGNIFICANT_WHITESPACE = 14 ;
XMLReader::END_ELEMENT = 15 ;
XMLReader::END_ENTITY = 16 ;
XMLReader::XML_DECLARATION = 17 ;
XMLReader::LOADDTD = 1 ;
XMLReader::DEFAULTATTRS = 2 ;
XMLReader::VALIDATE = 3 ;
XMLReader::SUBST_ENTITIES = 4 ;

¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ªÊoÐÔ¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¨C

a¡¢XMLReader->attributeCount ;
×÷ÓãºÊoÐÔÊýÁ¿

b¡¢XMLReader->baseURI ;
×÷Ó㺽ڵaµÄurl

c¡¢XMLReader->depth ;
×÷Ó㺽ڵaÊ÷µÄ²aÊý

d¡¢XMLReader->hasAttributes ;
×÷Ó㺼i²aÊÇ*ñÓÐÊoÐÔ

e¡¢XMLReader->hasValue ;
×÷ÓãºÊÇ*ñÓÐÖµ

f¡¢XMLReader->isEmptyElement ;
×÷ÓãºÊÇ*ñÊÇ¿Õ±eÇ(C)

g¡¢XMLReader->localName ;
×÷Ó㺱eÇ(C)ÄÚ²¿Ã÷

h¡¢XMLReader->name ;
×÷Ó㺱eÇ(C)Ãu

i¡¢XMLReader->nodeType ;
×÷Ó㺽ڵaÀaÐÍ

j¡¢XMLReader->value ;
×÷Ó㺽ڵaÎı¾ÄÚÈÝ

3¡¢XMLWriter

a¡¢XMLWriter::openURI
×÷Ó㺴ÓurlÊa³o´uÂe´´½¨ÐµÄXMLWriter
Ó裺XMLWriter::openURI(string uri )
²ÎÊý£ºurl xmlµØÖ

µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔo*µ»Ø FALSE¡£

b¡¢XMLWriter::setIndentString
×÷ÓãºÉeÖÃËo½ø×Öu
ÓÃ
¨£ºXMLWriter::setIndentString(string indentString )
²ÎÊý£ºindentString Ëo½ø×Öu
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

c¡¢XMLWriter::setIndent
×÷ÓãºÉeÖÃËo½ø¿ª¹Ø
Ó裺XMLWriter::setIndent(bool indent )
²ÎÊý£ºindent Ëo½øÓe
ñ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔo*µ»Ø FALSE¡£

d¡¢XMLWriter::startDocument
×÷ÓãºÉeÖÃÎĵµ¿ªÊ¼±eÇ(C)
Ó裺XMLWriter::startDocument( [string version [, string encoding [, string standalone]]] )
²ÎÊý£ºversion£¬°ae±¾£»encoding£¬±aÂe£»standalone£¬¶ÀÁ¢µÄ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

e¡¢XMLWriter::endDocument
×÷ÓãºÉeÖÃÎĵµ½aÊø±eÇ(C)
Ó裺XMLWriter::endDocument( )
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

f¡¢XMLWriter::startDTD
×÷ÓãºÉeÖÃdtd¿ªÊ¼±eÇ(C)
Ó裺XMLWriter::startDTD( string qualifiedName [, string publicId [, string systemId]] )
²ÎÊý£ºqualifiedName£¬Ãu³Æ£»publicId£¬piublic£»systemId£¬system
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

g¡¢XMLWriter::endDTD
×÷ÓãºÉeÖÃdtd½aÊø±eÇ(C)
Ó裺XMLWriter::endDTD()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

h¡¢XMLWriter::startElement
×÷ÓãºÉeÖÿªÊ¼±eÇ(C)
Ó裺XMLWriter::startElement(string name )
²ÎÊý£ºname£¬±eÇ(C)Ãu³Æ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

i¡¢XMLWriter::endElement
×÷ÓãºÉeÖýaÊø±eÇ(C)
Ó裺XMLWriter::endElement()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

j¡¢XMLWriter::startCData
×÷ÓãºÉeÖÿªÊ¼±eÇ(C)
Ó裺XMLWriter::startCData()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

k¡¢XMLWriter::endCData
×÷ÓãºÉeÖýaÊø±eÇ(C)
Ó裺XMLWriter::endCData ()
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

l¡¢XMLWriter::writeAttribute
×÷ÓãºÐ´±eÇ(C)ÊoÐÔ
Ó裺XMLWriter::writeAttribute (string name, string value )
²ÎÊý£ºname£¬ÊoÐÔÃu³Æ£»value£¬ÊoÐÔÖµ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

m¡¢XMLWriter::writeElement
×÷ÓãºÐ´±eÇ(C)ÊoÐÔ
Ó裺XMLWriter::writeElement (resource xmlwriter, string name, string content )
²ÎÊý£ºxmlwriter£¬xml×ÊÔ´£»name£¬±eÇ(C)Ãu³Æ£»value£¬Îı¾Öµ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

n¡¢XMLWriter::writeCData
×÷ÓãºÐ´±eÇ(C)ÊoÐÔ
Ó裺XMLWriter::writeCData (resource xmlwriter, string content )
²ÎÊý£ºxmlwriter£¬xml×ÊÔ´£»value£¬Îı¾Öµ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

o¡¢XMLWriter::text
×÷ÓãºÐ´Îı¾
Ó裺XMLWriter::text (string content )
²ÎÊý£ºcontent£¬Îı¾Öµ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

p¡¢XMLWriter::flush
×÷ÓãºÇa¿Õ»º´ae
Ó裺XMLWriter::flush ( )
²ÎÊý£ºÎÞ
µ»Ø£ºÈç¹u³É¹¦Ôoµ»Ø true£¬Ê§°ÜÔoµ»Ø FALSE¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例