Copied to clipboard

Flag this post as spam?

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


  • Sjors Pals 617 posts 270 karma points
    Jun 30, 2010 @ 16:27
    Sjors Pals
    0

    Umbraco base and returning multple nodes

    Hi i was wondering how this works, i want to use the umbraco rest feature to output xml that we wanna use on a google maps object, but i am stuck with the last peace of code, when i debug i see that the xml is availble, but when i return it, it always shows the entire XML document, can someone help me how to accomplish this?

    [code]

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    using umbraco.cms.businesslogic.web;
    using umbraco.BusinessLogic;
    using System.IO;
    using System.Xml.XPath;
    namespace Stadgenoot.Business
    {
        public class Rest
        {
            public static int Hello()
            {
                var x = umbraco.library.GetXmlNodeByXPath("root/descendant::Huurwoning");
                return x.count;
            }
        }
    }

    [/code]

    This works, it returns 21 objects, which is corret, but my question is, how do i output the xml of those?

     

     

     

  • Sjors Pals 617 posts 270 karma points
    Jun 30, 2010 @ 16:29
    Sjors Pals
    0

    Something went wrong with code:

     

     

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    using umbraco.cms.businesslogic.web;
    using umbraco.BusinessLogic;
    using System.IO;
    using System.Xml.XPath;
    namespace Stadgenoot.Business
    {
        public class Rest
        {
            public static int Hello()
            {

                var x = umbraco.library.GetXmlNodeByXPath("root/descendant::Huurwoning");

                return x.count;

            }
        }
    }

     

  • Jesper Hauge 298 posts 487 karma points c-trib
    Jun 30, 2010 @ 16:35
    Jesper Hauge
    1

    Here's an excerpt from the Umbraco Wiki Documentaton on /base: 

    "Your methods can have almost any return type. Base will convert your type to a string and return the result of the conversion. The string representation of your return type is produced by calling ToString() on the return type, which in many cases amounts to the name of the type.

    The only exception to this rule is your method returns a System.Xml.XPath.XPathNodeIterator, in which case /base will return the OuterXml of the Xml content of the XPathNodeIterator."

    Check 

    http://our.umbraco.org/wiki/reference/umbraco-base/programming-a-class-for-the-base-system

    For code examples.

     

    Regards
    Jesper Hauge

     

  • Sjors Pals 617 posts 270 karma points
    Jun 30, 2010 @ 16:49
    Sjors Pals
    0

    Yes, i was able to output xml, when i use:

    return umbraco.library.GetXmlNodeByXPath("root/descendant::Huurwoning");

    The problem is that the entire XML Document is returned, it doesn't seem to matter what kind of xpath expression i use, however, when i go in debug mode, i can see that the count is ok, the only problem is that i don't have an idea how i can return the right objects.

  • Phil Dye 149 posts 325 karma points
    Jul 22, 2010 @ 17:24
    Phil Dye
    0

    Ditto; GetXmlNodeByXPath seems to always result in the entire content tree, regardless of the xpath argument.


Please Sign in or register to post replies

Write your reply to:

Draft