PHP SimpleXML လုပ်ဆောင်ချက်များ
PHP SimpleXML နိဒါန်း
SimpleXML သည် ကျွန်ုပ်တို့အား အလွယ်တကူ စီမံခန့်ခွဲနိုင်ပြီး XML ဒေတာကို ရယူရန် ခွင့်ပြုသည့် တိုးချဲ့မှုတစ်ခုဖြစ်သည်။
SimpleXML သည် XML စာရွက်စာတမ်း၏ ဖွဲ့စည်းပုံ သို့မဟုတ် အပြင်အဆင်ကို သိပါက ဒြပ်စင်တစ်ခု၏ အမည်၊ ရည်ညွှန်းချက်များနှင့် စာသားအကြောင်းအရာကို ရရှိရန် လွယ်ကူသောနည်းလမ်းကို ပံ့ပိုးပေးပါသည်။
SimpleXML သည် XML စာရွက်စာတမ်းကို arrays နှင့် objects အစုအဝေးကဲ့သို့ သင်ထပ်ဆင့်ပြန်ဆိုနိုင်သည့် ဒေတာဖွဲ့စည်းပုံအဖြစ်သို့ ပြောင်းလဲပေးသည်။
တပ်ဆင်ခြင်း။
PHP 5 မှ၊ SimpleXML လုပ်ဆောင်ချက်များသည် PHP core ၏ အစိတ်အပိုင်းဖြစ်သည်။ ဤလုပ်ဆောင်ချက်များကိုအသုံးပြုရန် ထည့်သွင်းရန်မလိုအပ်ပါ။
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 Iteration Functions
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 |