PHP SimpleXML 함수
PHP SimpleXML 소개
SimpleXML은 XML 데이터를 쉽게 조작하고 가져올 수 있는 확장입니다.
SimpleXML은 XML 문서의 구조나 레이아웃을 알고 있는 경우 요소의 이름, 속성 및 텍스트 내용을 쉽게 얻을 수 있는 방법을 제공합니다.
SimpleXML은 XML 문서를 배열 및 개체 모음처럼 반복할 수 있는 데이터 구조로 바꿉니다.
설치
PHP 5부터 SimpleXML 함수는 PHP 코어의 일부입니다. 이러한 기능을 사용하기 위해 설치가 필요하지 않습니다.
PHP SimpleXML 함수
Function | Description |
---|---|
__construct() | Creates a new SimpleXMLElement object |
__toString() | Returns the string content of an element |
addAttribute() | Appends an attribute to the SimpleXML element |
addChild() | Appends a child element the SimpleXML element |
asXML() | Returns a well-formed XML string (XML version 1.0) from a SimpleXML object |
attributes() | Returns the attributes/values of an element |
children() | Returns the children of a specified node |
count() | Counts the children of a specified node |
getDocNamespaces() | Returns the namespaces declared in document |
getName() | Returns the name of an element |
getNamespaces() | Returns the namespaces used in document |
registerXPathNamespace() | Creates a namespace context for the next XPath query |
saveXML() | Alias of asXML() |
simplexml_import_dom() | Returns a SimpleXMLElement object from a DOM node |
simplexml_load_file() | Converts an XML document to an object |
simplexml_load_string() | Converts an XML string to an object |
xpath() | Runs an XPath query on XML data |
PHP SimpleXML 반복 함수
Function | Description |
---|---|
current() | Returns the current element |
getChildren() | Returns the child elements of the current element |
hasChildren() | Checks whether the current element has children |
key() | Returns the XML tag name of the current element |
next() | Moves to the next element |
rewind() | Rewinds to the first element |
valid() | Checks whether the current element is valid |