Copied to clipboard

Flag this post as spam?

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


  • Steve 15 posts 36 karma points
    Sep 11, 2011 @ 18:25
    Steve
    0

    GetXMLDocument Newbie Issue (can't even get the basics working)

    Hi all,

    I have tried the wiki entries and even some code from the forum but can't get this to work so clearly doing something daft.  To start getting it to return the data would be fantastic and then I will work away to get my more complex end solution, hopefully with not too many questions along the way!!

    note: myexcess.com is not public, its an internal DNS address but can return the XML in IE if I type the address in on the server.

    Thanks in Advance!!!

    XML

    - <ProductDetails>
      <AgencyID>1234</AgencyID>
      <ProductID>199</ProductID>
      <GBP_SelloutRate>GBP_SelloutRate_0</GBP_SelloutRate>
      <GBP_SelloutDiscountAmount>GBP_SelloutDiscountAmount_0</GBP_SelloutDiscountAmount>
      <GBP_SelloutDiscountPercentage>GBP_SelloutDiscountPercentage_0</GBP_SelloutDiscountPercentage>
      <GBP_SelloutDiscountRate>GBP_SelloutDiscountRate_0</GBP_SelloutDiscountRate>
      <EUR_SelloutRate>EUR_SelloutRate_0</EUR_SelloutRate>
      <EUR_SelloutDiscountAmount>EUR_SelloutDiscountAmount_0</EUR_SelloutDiscountAmount>
      <EUR_SelloutDiscountPercentage>EUR_SelloutDiscountPercentage_0</EUR_SelloutDiscountPercentage>
      <EUR_SelloutDiscountRate>EUR_SelloutDiscountRate_0</EUR_SelloutDiscountRate>
      <ProductDesc>ProductDesc_0</ProductDesc>
      </ProductDetails>
      </ns0:Agency>

    XSLT:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:template match="/">

    <!-- start writing XSLT -->

    <xsl:variable name="MyFeed" select="umbraco.library:GetXmlDocumentByUrl('http://myexcess.com/Agency_Price_Lookup_output.xml')" />
    <ul>
      <html>
      <body>
      <h2>Excess Products</h2>
      <table border="1">
        <tr bgcolor="#9acd32">
          <th>Product</th>
        </tr>
        <xsl:for-each select="$MyFeed/Agency/ProductDetails">
        <tr>
          <li><td><xsl:value-of select="ProductID"/></td></li>
        </tr>
        </xsl:for-each>
      </table>
      </body>
      </html>
    </ul>

    </xsl:template>
    </xsl:stylesheet>

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Sep 11, 2011 @ 19:57
    Chriztian Steinmeier
    0

    Hi Steve,

    It's probably just a namespace issue - you need to declare a prefix for the (albeit weird) namespace that the root element of the XML is wrapped in - and then you need to use that prefix when addressing said element:

    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:umb="urn:umbraco.library"
        xmlns:ns0="http://BizTalk_Server_Project1.Agency_Price_Lookup"
        exclude-result-prefixes="umb ns0"
    >
    
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
        <xsl:param name="currentPage" />
    
        <xsl:template match="/">
            <xsl:variable name="MyFeed" select="umbraco.library:GetXmlDocumentByUrl('http://myexcess.com/Agency_Price_Lookup_output.xml')" /> 
                <html>
                <body>
                    <h2>Excess Products</h2>
                    <table border="1">
                        <tr bgcolor="#9acd32">
                            <th>Product</th>
                        </tr>
                        <xsl:for-each select="$MyFeed/ns0:Agency/ProductDetails">
                            <tr>
                                <td><xsl:value-of select="ProductID"/></td>
                            </tr>
                        </xsl:for-each>
                    </table>
                </body>
                </html>
        </xsl:template>
    </xsl:stylesheet>

    (I removed som strange <ul> & <li> stuff that probably shouldn't go there - feel free to add them back in, if needed...)

    /Chriztian

  • Steve 15 posts 36 karma points
    Sep 11, 2011 @ 20:24
    Steve
    0

    Many Thanks Chriztian,

    It has been doing my head in.....   The weird namespace is mainly from the fact that I do the core work for my application in Biztalk, schemas are managed there so may as well keep it consistent.  The ul and li was me stabbing in the dark at the end.

    Will give this a go now and let you know.

    I have got the hard bit to do next, that should be interesting, but not for today.


    Steve.

  • Steve 15 posts 36 karma points
    Sep 11, 2011 @ 20:36
    Steve
    0

    Works a treat, thanks Chriztian. 

  • Steve 15 posts 36 karma points
    Sep 11, 2011 @ 20:37
    Steve
    0

    Works a treat, thanks Chriztian. 

Please Sign in or register to post replies

Write your reply to:

Draft