Php code for adding xml node attributes
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
2. php code
- $ Dom = new DOMDocument ('1. 0 ');
- $ Dom-> load ('x. XML ');
- $ Em = $ dom-> getElementsByTagName ('Emotions ');
- $ Em = $ em-> item (0 );
- $ Items = $ em-> getElementsByTagName ('ITEM ');
- Foreach ($ items as $ ){
- Foreach ($ a-> attributes as $ B ){
- If ($ B-> nodeValue = 'birthday '){
- $ A-> setAttribute ('name', 'nbirthday ');
- }
- }
- }
- $ T = $ dom-> createElement ('ITEM ');
- $ T-> setAttribute ('name', 'x ');
- $ T-> setAttribute ('src', 'www .sohu.com ');
- $ T-> setAttribute ('duration', 'duration ');
- $ Em-> appendChild ($ t );
- $ Dom-> save ('x. XML ');
- ?>
-
Recommended for script School editing: php parses XML document attributes and edits code php xml Document parsing function learning instance php parses XML data a piece of code PHP reads XML several methods php uses the DOM class to read XML file code instance learn the DOMDocument class for php to operate XML |