We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44649
    • 68 Posts
    Hey,

    I have some XML which is formatted like this
    <property>
      <id>20</id>
      <address>
        <propertyname>Almond Tree Cottage</propertyname>
        <street>Long Wittenham Road</street>
        <locality/>
        <town>Didcot</town>
      </address>
    </property>
    


    I have the item value set as `property` and can access direct childNode i.e. [[+id]], [[+addeddate]] but can't access children of those nodes.

    I can see them in the debug output as objects
    ["address"]=> object(SimpleXMLElement)#91 (12) { ["propertyname"]=> object(SimpleXMLElement)#96 (0) { } ["street"]=> string(19) "81 Wallingford Road" ["locality"]=> string(7) "Cholsey" ["town"]=> string(11) "Wallingford" ["region"]=> string(11) "Oxfordshire" ["postcode"]=> string(8) "OX10 9LB" ["countrycode"]=> string(3) "826" ["housenumber"]=> string(2) "81" ["streetname"]=> string(16) "Wallingford Road" ["latitude"]=> string(8) "51.57853" ["longitude"]=> string(8) "-1.14798" ["area"]=> string(7) "Cholsey" }


    Would anyone know how to do this? I'm guessing I need another loop within parseX

    Thanks
      • 17301
      • 932 Posts
      Old post but yes you can embed another parsex call into your tpl ie:

      For example

      [[parsex? &source=`myfile.xml` &tpl=`xmlTpl` &debugmode=`true` &limit=`0` &element=`property`]]


      xmlTpl
      [[+id]]
      [[parsex? &source=`myfile.xml` &tpl=`xmlTpl2` &debugmode=`true` &limit=`0` &element=`address`]]


      xmlTpl2
      [[+street]]
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.