Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Vingaard 39 posts 60 karma points
    Sep 27, 2011 @ 11:29
    Martin Vingaard
    0

    Rookie: XML external sitemap in Unbraco Xslt

    Im trying to get the sitemap of an external page so that i can return it within umbraco.

    Is it enough to add the:  

    <?xe.target ..domain.com/user.xml?user=77765&return=xml&per_page=1000?>

    at the 2nd line or is there more to it? (i guess there is since it isnt working atm).

    Ive been looking through w3school and google and somehow i can't find anything usefull to me regarding linking to an external xml file.

    The code as it is now (there is hardly any)

    <?xml version="1.0" encoding="UTF-8"?>
    <?xe.target ..http://www.domain.com/user.xml?user=5555&return=xml&per_page=100?>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">

      <xsl:for-each select="listings/listing">
        <xsl:value-of select="description"/>
      </xsl:for-each>
      
    </xsl:template>
    </xsl:stylesheet>

     

    Thanks in advance

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Sep 27, 2011 @ 11:48
    Chriztian Steinmeier
    0

    Hi Martin,

    Adding the xs.target processing instruction won't do anything in Umbraco, but there's an extension function available for you:

    <xsl:variablename="feed"select="umbraco.library:GetXmlDocumentByUrl('http://www.domain.com/user.xml?user=5555&amp;return=xml&amp;per_page=100', 300)"/>

    (the second argument is the number of seconds Umbraco should cache the result)

    Then you'd change the for-each to grab from that variable (making sure to select from the root):

    <xsl:for-eachselect="$feed/listings/listing">

    /Chriztian

  • Martin Vingaard 39 posts 60 karma points
    Sep 27, 2011 @ 12:22
    Martin Vingaard
    0

    thanks alot for your response

    and i see the logic in that. Though i get an error now regarding the URL.
    Seems as if the return=xml statement in the link is causing an error.

    System.Xml.XmlException: '=' is an unexpected token. The expected token is ';'. Line 12, position 120. 

    /Martin

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Sep 27, 2011 @ 12:40
    Chriztian Steinmeier
    0

    Hi Martin,

    My bad - copy & paste error :-)

    In XML (and HTML too, actually) you have to escape ampersands (&) like this: &amp;

    I've corrected the code above.

    /Chriztian

  • Martin Vingaard 39 posts 60 karma points
    Sep 27, 2011 @ 12:46
    Martin Vingaard
    0

    Hi Chriztian i was just about to post the same :)

    Thanks again.

Please Sign in or register to post replies

Write your reply to:

Draft