SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    updating xml fields

    i have problem updating the xml textnodes.
    my problem is how could i update the text content of the node
    profile>user>address>address3 or any other nodes.
    i recently got in to this site because i already used domdocument to for parsing xml text nodes. but the site is lacking some examples and it was very hard for me to implement this.
    i hope someone could help me. thanks..
    Code XML:
    <profile>
    	<user>
    		<firstname>steve</firstname>
    		<middlename>torvalds</middlename>
    		<lastname>gates</lastname>
    		<age>29</age>
    		<gender>m</gender>
    		<address>
    			<address1>#8 cameron</address1>
    			<address2>valero compound</address2>
    			<address3></address3>
    			<zip>22222</zip>
    			<country>england</country>
    		</address>
    		<contactnumber>01199911100</contactnumber>
    	</user>
    	<familycontact>
    		<firstname>aries</firstname>
    		<lastname>clarens</lastname>
    		<age>54</age>
    		<gender>m</gender>
    		<address>
    			<address1>#222 jupiter</address1>
    			<address2>sorento village</address2>
    			<address3>st. peters</address3>
    			<country>italy</country>
    		</address>
    		<contactnumber>999222888</contactnumber>
    	</familycontact>
    	<business>
    		<companyname>the associates inx</companyname>
    		<address>england</address>
    		<landline>875675</landline>
    		<fax>867832</fax>
    	</business>
    </profile>

  2. #2
    SitePoint Zealot Amenthes's Avatar
    Join Date
    Oct 2006
    Location
    Bucharest, Romania
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The best approach for text nodes is using DOMNode::nodeValue:

    http://www.php.net/manual/en/class.d...rops.nodevalue

    Alternatively, you could use DOMNode::replaceChild() or, in case there's no content in the
    node, DOMNode::appendChild();
    I'm under construction | http://igstan.ro/


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •