php - Select element in XML, same node name different attribute -


i have following xml , need fill data array. problem has 3 nodes name "contact" each of them have different attribute. tried using xpath didnt not managed make work kept getting errors. think syntax error.

sample of xml

<command> <create> <domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0" xsi:schemalocation="urn:ietf:params:xml:ns:domain-1.0 domain-1.0.xsd"> <domain:name>0000</domain:name> <domain:period unit="y">2</domain:period> <domain:ns> <domain:hostobj>0000</domain:hostobj> </domain:ns> <domain:registrant>0000</domain:registrant> <domain:contact type="tech">000</domain:contact> <domain:contact type="admin">000</domain:contact> <domain:contact type="billing">000</domain:contact> <domain:authinfo> <domain:pw>000</domain:pw> </domain:authinfo> </domain:create> </create> <cltrid>abc:ics-forth:1079691187887</cltrid> </command> </epp> 

and below code

        $p2xml = new simplexmlelement($p2xmlf);         foreach ($p2xml->command->create $entry2)         {             $namespaces = $entry2->getnamespaces(true);             $dc = $entry2->children($namespaces['domain']);             $dc->create->name = $domain_fields['name'];             $dc->create->ns->hostobj = $domain_fields['ns1'];             $dc->create->ns->hostobj = $domain_fields['ns2'];             $dc->create->registrant = $domain_fields['registrant'];             $dc->create->contact = $domain_fields['contact']; <-- problem here             $dc->create->contact = $domain_fields['contact']; <-- problem here             $dc->create->contact = $domain_fields['contact']; <-- problem here             $dc->create->authinfo->pw = $domain_fields['pw'];              $oxml = $p2xml->asxml(); 

tried replacing contact //contact[@type=['tech'] , others i'm stuck

i don't know if php api accepts xpath, if does, xpath want use select each of 3 elements be:

 //contact[@type='tech'] //contact[@type='admin'] //contact[@type='billing'] 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -