Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

How To Parse This Xml

xml

  • Please log in to reply
3 replies to this topic

#1 Hamed

Hamed

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 413 posts

Posted 22 April 2012 - 04:22 AM

Hello,
I have XML file like bellow:
<?xml version="1.0" encoding="UTF-8"?>
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:domain="http://epp.nic.ir/ns/domain-1.0">
  <response xmlns:domain="http://epp.nic.ir/ns/domain-1.0">
    <result code="1000">
	  <msg>Command completed successfully</msg>
    </result>
    <resData xmlns:domain="http://epp.nic.ir/ns/domain-1.0">
	  <domain:chkData xmlns:domain="http://epp.nic.ir/ns/domain-1.0">
	    <domain:cd>
		  <domain:name normalized_name="ghasemzadeh" canonized_name="ghasemzadeh" tld="ir" avail="0">ghasemzadeh.ir</domain:name>
	    </domain:cd>
	  </domain:chkData>
    </resData>
    <trID>
	  <clTRID>**-880818307</clTRID>
	  <svTRID>IRNIC_2012-04-22T16:48:39+04:30_x4m</svTRID>
    </trID>
  </response>
</epp>
in this xml I need code in result tag <result code="1000"> and also in
<domain:name normalized_name="ghasemzadeh" canonized_name="ghasemzadeh" tld="ir" avail="0">ghasemzadeh.ir</domain:name>
I need avail
please help me
  • 0

#2 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others

Posted 22 April 2012 - 06:07 AM

http://us2.php.net/xml
  • 0

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#3 John

John

    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 22 April 2012 - 07:16 AM

Or (my preference)http://us2.php.net/m...k.simplexml.php
  • 0

#4 Hamed

Hamed

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 413 posts

Posted 23 April 2012 - 09:15 PM

I can not get : avail in
<domain:name normalized_name="ghasemzadeh" canonized_name="ghasemzadeh" tld="ir" avail="0">ghasemzadeh.ir</domain:name>
can anyone show me simple code?
	   $dom = new DOMDocument;
	   $dom->loadXML($response);
	   $ress = $dom->getElementsByTagName('result');
	   foreach($ress as $res){
		   $code = $res -> getAttribute('code');
	   }
	   $avs = $dom->getElementsByTagName('domain:name');
	   foreach($avs as $av){
		   $avail = $av -> getAttribute('avail');
	   }
	   $s = array($code, $avail);

  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download