Can explain this block Code to me PHP XML DOMDocument Syntax -


I am currently learning different ways using XML document tags, using the php DOMDocument object, I Understand foreach to loop through the tag, but $ element-> Items (0) - & gt; Child nodes-> Items (0) - & gt; Node Vela is not quite clear Is anyone can tell me in detail? Thank you.

  & lt ;? Php $ xmlDoc = new DOMDocument (); $ XmlDoc- & gt; Load ('StudentData.xml'); $ StudentRoot = $ xmlDoc- & gt; GetElementsByTagName ('student'); ($ I = $; $ i & lt; ($ studentRoot- & gt; Length); $ i ++) {$ firstNameTags = $ studentRoot- & gt; Items ($ i) - & gt; GetElementsByTagName ('first name'); Echo $ First Name Tag- & gt; Items (0) - & gt; Child nodes-> Items (0) - & gt; Node vale '& Lt; Br / & gt; '; } / * So simple and clear to understand! * / Foreach ($ student $$ root as node) {/ * each & lt; Students & gt; Tag it as a separate node, move it into the child's node, and for each child, echo the text content * / foreach ($ node-> as childNodes $$) {echo $ child- & Gt; TextContent & Lt; Br / & gt; '; }}? & Gt;    

  $ element-> Items (0) - & gt; ChildNodes- & Gt; Items (0) - & gt;       

/ Strong> In parse and referenced code example, this would be:

  $ firstNameTags = $ studentRoot- & gt; Items ($ i) - & gt; GetElementsByTagName ('first name'); $ FirstNameTags-> ...   

Next:

  - & gt; A reference before item (0)   

go $ elements because it is zero-indexed, so -> Index <> -> In the list in the list item (0) ChildNodes

Get a list of referenced by that $ Elements node> - & gt; Item (0) above is not a () , this is a (read only) DOMNodeList property .

  Again, get the first node in the list of hair nodes by  index .  
  - & gt; Nodevela   

by itself.


If the state is:

  $ obj-> gt; Method () - & gt; Method () - & gt; Sahay   

To tell you, check, which uses all the method to call simultaneously. < $ note, you have left s , but this indicates That is one or more possible by the conference . Then the $ element element will be zero or one , the $ element can be zero, one or more of the $ element in a collection of $ .

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -