Re: [PHP] Adressing XML Objects
Try it with just one / at the start of the xpath. /anbieter/immobilie/... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adressing XML Objects
Hello nathan, I am unsing simplexml as it looks really simple :-) However, I could still not figure out how to adress data inside tags with attributes. For example: anhang location=INTERN gruppe=TITELBILD databla blub/data $xml-anhang[intern][titelbild]-data will not work. Thank you for any hint. Best regards, Merlin Merlin Morgenstern schrieb: Hello Nathan, I upgraded to PHP 5, so I am using nativ support. Best regards, Merlin Nathan Nobbe schrieb: On Wed, Jan 7, 2009 at 1:10 PM, Merlin Morgenstern merli...@fastmail.fm mailto:merli...@fastmail.fm wrote: Hi there, I am justing walking my first steps on XML and PHP. As I learned from a tutorial adressing is very simple: echo $xml-anbieter-immobilie-preise-kaufpreis; this is meaningless unless we know which xml library you are using. i believe you said youre running php4 earlier, right? so which xml library have you settled on? btw; php4 has DOMXML as a native extension, but the api is a bit cumbersome. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adressing XML Objects
On Thu, Jan 8, 2009 at 4:02 PM, Merlin Morgenstern merli...@fastmail.fmwrote: Hello nathan, I am unsing simplexml as it looks really simple :-) However, I could still not figure out how to adress data inside tags with attributes. For example: anhang location=INTERN gruppe=TITELBILD databla blub/data $xml-anhang[intern][titelbild]-data will not work. again, ill need some clarification. are you trying to get the data node directly, OR, are you trying to get the contents of all nodes which are descendants of anhang nodes, w/ attributes location and gruppe, having values INTERN and TITLEBILD respectively? these are two different the things, the former being, well simple $xml-anhang-data the latter i would do via xpath, which SimpleXML supports as well. -nathan
Re: [PHP] Adressing XML Objects
Nathan Nobbe wrote: On Thu, Jan 8, 2009 at 4:02 PM, Merlin Morgenstern merli...@fastmail.fmwrote: Hello nathan, I am unsing simplexml as it looks really simple :-) However, I could still not figure out how to adress data inside tags with attributes. For example: anhang location=INTERN gruppe=TITELBILD databla blub/data $xml-anhang[intern][titelbild]-data will not work. again, ill need some clarification. are you trying to get the data node directly, OR, are you trying to get the contents of all nodes which are descendants of anhang nodes, w/ attributes location and gruppe, having values INTERN and TITLEBILD respectively? these are two different the things, the former being, well simple $xml-anhang-data the latter i would do via xpath, which SimpleXML supports as well. -nathan I think you hit the nail on the head with XPath nathan; //anha...@location='INTERN' and @gruppe='TITELBILD']/data which would be requiring DOMDocument and DOMXPath ?php $xml = 'your xml here'; $doc = new DOMDocument; $doc-loadXML($xml); $xpath = new DOMXPath($doc); $query = '//anha...@location='INTERN' and @gruppe='TITELBILD']/data'; $entries = $xpath-query($query); // for loop the entries or whatever here.. ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adressing XML Objects
On Thu, Jan 8, 2009 at 4:38 PM, Nathan Rixham nrix...@gmail.com wrote: Nathan Nobbe wrote: On Thu, Jan 8, 2009 at 4:02 PM, Merlin Morgenstern merli...@fastmail.fm wrote: Hello nathan, I am unsing simplexml as it looks really simple :-) However, I could still not figure out how to adress data inside tags with attributes. For example: anhang location=INTERN gruppe=TITELBILD databla blub/data $xml-anhang[intern][titelbild]-data will not work. again, ill need some clarification. are you trying to get the data node directly, OR, are you trying to get the contents of all nodes which are descendants of anhang nodes, w/ attributes location and gruppe, having values INTERN and TITLEBILD respectively? these are two different the things, the former being, well simple $xml-anhang-data the latter i would do via xpath, which SimpleXML supports as well. -nathan I think you hit the nail on the head with XPath nathan; //anha...@location='INTERN' and @gruppe='TITELBILD']/data which would be requiring DOMDocument and DOMXPath ive been really lazy about testing stuff first today :), but why not just rock it out w/ SimpleXML, $xml = new SimpleXMLElement($xmlstr); $searchResult = $xml-xpath('//anha...@location='INTERN' and @gruppe='TITELBILD']/data'); at least im just saying you dont NEED DOMDocument DOMXPath, but def, that is an alternative to SimpleXML. -nathan
Re: [PHP] Adressing XML Objects
Nathan Nobbe wrote: On Thu, Jan 8, 2009 at 4:38 PM, Nathan Rixham nrix...@gmail.com mailto:nrix...@gmail.com wrote: Nathan Nobbe wrote: On Thu, Jan 8, 2009 at 4:02 PM, Merlin Morgenstern merli...@fastmail.fm mailto:merli...@fastmail.fmwrote: Hello nathan, I am unsing simplexml as it looks really simple :-) However, I could still not figure out how to adress data inside tags with attributes. For example: anhang location=INTERN gruppe=TITELBILD databla blub/data $xml-anhang[intern][titelbild]-data will not work. again, ill need some clarification. are you trying to get the data node directly, OR, are you trying to get the contents of all nodes which are descendants of anhang nodes, w/ attributes location and gruppe, having values INTERN and TITLEBILD respectively? these are two different the things, the former being, well simple $xml-anhang-data the latter i would do via xpath, which SimpleXML supports as well. -nathan I think you hit the nail on the head with XPath nathan; //anha...@location='INTERN' and @gruppe='TITELBILD']/data which would be requiring DOMDocument and DOMXPath ive been really lazy about testing stuff first today :), but why not just rock it out w/ SimpleXML, $xml = new SimpleXMLElement($xmlstr); $searchResult = $xml-xpath('//anha...@location='INTERN' and @gruppe='TITELBILD']/data'); at least im just saying you dont NEED DOMDocument DOMXPath, but def, that is an alternative to SimpleXML. -nathan nice clarification namesake - I've always just dived right in to DOMDocuments and never gave simplexml much weight; but that's no reflection on simplexml :p -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adressing XML Objects
ok... it seems that I am doing something fundamentally wrong. I get no output at all with this: $xmlStr = file_get_contents($filename); $xmlelement = new SimpleXMLElement($xmlStr); echo '$xmlelement-xpath(//anbieter/immobilie/anhaenge/anha...@location='INTERN' and @gruppe='TITELBILD']/daten/anhanginhalt); The names and structure seems fine. The syntax according to your posting and php.net also. Any ideas? Thanx Merlin Nathan Nobbe schrieb: On Thu, Jan 8, 2009 at 4:38 PM, Nathan Rixham nrix...@gmail.com mailto:nrix...@gmail.com wrote: Nathan Nobbe wrote: On Thu, Jan 8, 2009 at 4:02 PM, Merlin Morgenstern merli...@fastmail.fm mailto:merli...@fastmail.fmwrote: Hello nathan, I am unsing simplexml as it looks really simple :-) However, I could still not figure out how to adress data inside tags with attributes. For example: anhang location=INTERN gruppe=TITELBILD databla blub/data $xml-anhang[intern][titelbild]-data will not work. again, ill need some clarification. are you trying to get the data node directly, OR, are you trying to get the contents of all nodes which are descendants of anhang nodes, w/ attributes location and gruppe, having values INTERN and TITLEBILD respectively? these are two different the things, the former being, well simple $xml-anhang-data the latter i would do via xpath, which SimpleXML supports as well. -nathan I think you hit the nail on the head with XPath nathan; //anha...@location='INTERN' and @gruppe='TITELBILD']/data which would be requiring DOMDocument and DOMXPath ive been really lazy about testing stuff first today :), but why not just rock it out w/ SimpleXML, $xml = new SimpleXMLElement($xmlstr); $searchResult = $xml-xpath('//anha...@location='INTERN' and @gruppe='TITELBILD']/data'); at least im just saying you dont NEED DOMDocument DOMXPath, but def, that is an alternative to SimpleXML. -nathan
Re: [PHP] Adressing XML Objects
Merlin Morgenstern wrote: ok... it seems that I am doing something fundamentally wrong. I get no output at all with this: $xmlStr = file_get_contents($filename); $xmlelement = new SimpleXMLElement($xmlStr); echo '$xmlelement-xpath(//anbieter/immobilie/anhaenge/anha...@location='INTERN' and @gruppe='TITELBILD']/daten/anhanginhalt); The names and structure seems fine. The syntax according to your posting and php.net also. Any ideas? yup echo in the wrong place, try: $xmlStr = file_get_contents($filename); $xmlelement = new SimpleXMLElement($xmlStr); $result = '$xmlelement-xpath(//anbieter/immobilie/anhaenge/anha...@location='INTERN' and @gruppe='TITELBILD']/daten/anhanginhalt); while(list( , $node) = each($result)) { print_r($node); } failing that, keep shortening the xpath query till you get one that works then go from there -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adressing XML Objects
Merlin Morgenstern wrote: ok... it seems that I am doing something fundamentally wrong. I get no output at all with this: $xmlStr = file_get_contents($filename); $xmlelement = new SimpleXMLElement($xmlStr); echo '$xmlelement-xpath(//anbieter/immobilie/anhaenge/anha...@location='INTERN' and @gruppe='TITELBILD']/daten/anhanginhalt); The names and structure seems fine. The syntax according to your posting and php.net also. Any ideas? yup echo in the wrong place, try: $xmlStr = file_get_contents($filename); $xmlelement = new SimpleXMLElement($xmlStr); $result = $xmlelement-xpath(//anbieter/immobilie/anhaenge/anha...@location='INTERN' and @gruppe='TITELBILD']/daten/anhanginhalt); while(list( , $node) = each($result)) { print_r($node); } failing that, keep shortening the xpath query till you get one that works then go from there -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adressing XML Objects
On Wed, Jan 7, 2009 at 3:10 PM, Merlin Morgenstern merli...@fastmail.fm wrote: Hi there, I am justing walking my first steps on XML and PHP. As I learned from a tutorial adressing is very simple: echo $xml-anbieter-immobilie-preise-kaufpreis; I simply just can't figure out how to adress this structure: anhang location=INTERN gruppe=TITELBILD This does not work: echo $xml-anbieter-immobilie-anhaenge-daten-anhanginhalt; Somehow location and gruppe needs to be placed into the command. I already tried a couple of version, but no success. Thank you for any hint. Best regards, Merlin I haven't used SimpleXML too much, but aren't you just looking for this? $attributes = $xml-anbieter-immobilie-anhaenge-daten-anhanginhalt-anhang-attributes(); echo $attributes['location'], \n; echo $attributes['gruppe'], \n; http://www.php.net/manual/en/function.simplexml-element-attributes.php Andrew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adressing XML Objects
On Wed, Jan 7, 2009 at 1:10 PM, Merlin Morgenstern merli...@fastmail.fmwrote: Hi there, I am justing walking my first steps on XML and PHP. As I learned from a tutorial adressing is very simple: echo $xml-anbieter-immobilie-preise-kaufpreis; this is meaningless unless we know which xml library you are using. i believe you said youre running php4 earlier, right? so which xml library have you settled on? btw; php4 has DOMXML as a native extension, but the api is a bit cumbersome. -nathan
Re: [PHP] Adressing XML Objects
Hello Nathan, I upgraded to PHP 5, so I am using nativ support. Best regards, Merlin Nathan Nobbe schrieb: On Wed, Jan 7, 2009 at 1:10 PM, Merlin Morgenstern merli...@fastmail.fm mailto:merli...@fastmail.fm wrote: Hi there, I am justing walking my first steps on XML and PHP. As I learned from a tutorial adressing is very simple: echo $xml-anbieter-immobilie-preise-kaufpreis; this is meaningless unless we know which xml library you are using. i believe you said youre running php4 earlier, right? so which xml library have you settled on? btw; php4 has DOMXML as a native extension, but the api is a bit cumbersome. -nathan
Re: [PHP] Adressing XML Objects
On Wed, Jan 7, 2009 at 1:42 PM, Merlin Morgenstern merli...@fastmail.fmwrote: Hello Nathan, I upgraded to PHP 5, so I am using nativ support. Best regards, Merlin please keep replies on-list so others may benefit from the archives. OK, native support; so in php5 you can use DOM or SimpleXML, i assume you're using SimpleXML, but for clarification, this is the sort of detail you should include in an initial question, otherwise we wont be able to help much. -nathan
Re: [PHP] Adressing XML Objects
Merlin Morgenstern wrote: Hello Nathan, I upgraded to PHP 5, so I am using nativ support. Best regards, Merlin Nathan Nobbe schrieb: On Wed, Jan 7, 2009 at 1:10 PM, Merlin Morgenstern merli...@fastmail.fm mailto:merli...@fastmail.fm wrote: Hi there, I am justing walking my first steps on XML and PHP. As I learned from a tutorial adressing is very simple: echo $xml-anbieter-immobilie-preise-kaufpreis; this is meaningless unless we know which xml library you are using. i believe you said youre running php4 earlier, right? so which xml library have you settled on? btw; php4 has DOMXML as a native extension, but the api is a bit cumbersome. -nathan Then how about and example of the commands you are using to convert your xml to php hash... -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adressing XML Objects
Jim Lucas wrote: Merlin Morgenstern wrote: Hello Nathan, I upgraded to PHP 5, so I am using nativ support. Best regards, Merlin Nathan Nobbe schrieb: On Wed, Jan 7, 2009 at 1:10 PM, Merlin Morgenstern merli...@fastmail.fm mailto:merli...@fastmail.fm wrote: Hi there, I am justing walking my first steps on XML and PHP. As I learned from a tutorial adressing is very simple: echo $xml-anbieter-immobilie-preise-kaufpreis; this is meaningless unless we know which xml library you are using. i believe you said youre running php4 earlier, right? so which xml library have you settled on? btw; php4 has DOMXML as a native extension, but the api is a bit cumbersome. -nathan Then how about and example of the commands you are using to convert your xml to php hash... or object as it seems -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php