Xml query

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
masama1
Forum Members
Forum Members
Posts: 10
Joined: Thu Jul 08, 2010 8:44 am

Xml query

Post by masama1 »

I have quite large xml file on different server and i want to make queries from file. Is there any tools to intergrate xml from external source? Anyone interested in to take a look?
totophe
Forum Members
Forum Members
Posts: 63
Joined: Wed Feb 21, 2007 9:30 am

Re: Xml query

Post by totophe »

You can use XML Made Simple.

It will generate an "SimpleXML" Object (http://php.net/manual/en/book.simplexml.php) that you can use in your templates.

You can access it in smarty via the {$xml} variable.

A good way to start is to do a {$xml|var_dump} to show the variables you can access to.
masama1
Forum Members
Forum Members
Posts: 10
Joined: Thu Jul 08, 2010 8:44 am

Re: Xml query

Post by masama1 »

Sorry i'm not following. i managed to do CD catalog tutorial (http://www.w3schools.com/XML/xml_examples.asp) but if i try to use same logic with my own XML (www.edeamedia.com/testi/testi.xml-> does not work at all.

Compare:
CD Catalog example:
{foreach from=$xml->CD item=CD}
{$CD->ARTIST}
{/foreach}

And my XML:
{foreach from=$xml->item id="439070" itemType="kivihomepagetransfer" item=property name="country_id"}
{$property name="country_id"->value}
{/foreach}
totophe
Forum Members
Forum Members
Posts: 63
Joined: Wed Feb 21, 2007 9:30 am

Re: Xml query

Post by totophe »

Play with the following code:

Code: Select all

{foreach from=$xml->item item=element}
  {foreach from=$element->property item=prop}
    <pre>
      {foreach from=$prop->attributes() item=attribute key=name}
        attribute: {$attribute}
        key: {$name}
      {/foreach}

      value: {$prop->value}
    </pre>
  {/foreach}
{/foreach}
masama1
Forum Members
Forum Members
Posts: 10
Joined: Thu Jul 08, 2010 8:44 am

Re: Xml query

Post by masama1 »

Ok, now i can get whole package. If i want to pick just two values


  Kivinen
  and

  matti.liljaniemi@jatkoaika.com
 

how should i proceed?
foreach loop for every value? ::)
Post Reply

Return to “Modules/Add-Ons”