From XmlNode to string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeppe BS

    #1

    From XmlNode to string

    hi

    I got an XmlNode called xNode
    Is there a way to convert it so it fits into a string ?
  • Jon Skeet [C# MVP]

    #2
    Re: From XmlNode to string

    Jeppe BS <hundehviskeren @hotmail.com> wrote:[color=blue]
    > I got an XmlNode called xNode
    > Is there a way to convert it so it fits into a string ?[/color]

    Well what do you want from it in terms of a string representation?
    There are various methods which convert it into different string
    representations , but you'll need to know exactly what you want before
    you can really pick one.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Gary van der Merwe

      #3
      Re: From XmlNode to string

      Hi

      Try using the xml propetery. This gives you the xml in a string.

      Gary

      "Jeppe BS" <hundehviskeren @hotmail.com> wrote in message
      news:e1df179e.0 310100131.22bed 41c@posting.goo gle.com...[color=blue]
      > hi
      >
      > I got an XmlNode called xNode
      > Is there a way to convert it so it fits into a string ?[/color]


      Comment

      • Jeppe Svendsen

        #4
        Re: From XmlNode to string

        hmm weird
        i started this thread from google groups and when i wanted to answer i
        had to sign up for an account?? How did i t happen in the first place ??

        Anyway
        got this webmethod (using Web Matrix) and it should return a string. I
        pick out the XmlNode i want and try to return it.
        code

        XmlNode personNode;
        XmlNode root = personDB.Docume ntElement;

        personNode = root.SelectSing leNode("/person[navn='Jeppe']");

        // can i do this ??
        string wayout = personNode.Oute rXml;

        return wayout;






        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Jon Skeet [C# MVP]

          #5
          Re: From XmlNode to string

          Jeppe Svendsen <hundehviskeren @hotmail.com> wrote:[color=blue]
          > Anyway
          > got this webmethod (using Web Matrix) and it should return a string. I
          > pick out the XmlNode i want and try to return it.
          > code
          >
          > XmlNode personNode;
          > XmlNode root = personDB.Docume ntElement;
          >
          > personNode = root.SelectSing leNode("/person[navn='Jeppe']");
          >
          > // can i do this ??
          > string wayout = personNode.Oute rXml;
          >
          > return wayout;[/color]

          I'm sure you *can* do that - but whether or not it's the string you
          *want* to return, I don't know. What are you passing this string to
          afterwards? What format is it expected to be in?

          --
          Jon Skeet - <skeet@pobox.co m>
          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

          If replying to the group, please do not mail me too

          Comment

          • Nicholas Paldino [.NET/C# MVP]

            #6
            Re: From XmlNode to string

            Jeppe,

            You can not convert it so it fits in a string, so to speak, but you can
            get the value from the XmlNode by using the Value property on the XmlNode
            instance. Also, you can use the InnerXml and OuterXml properties to get the
            of the node.

            Hope this helps.


            --
            - Nicholas Paldino [.NET/C# MVP]
            - nick(dot)paldin o=at=exisconsul ting<dot>com

            "Jeppe BS" <hundehviskeren @hotmail.com> wrote in message
            news:e1df179e.0 310100131.22bed 41c@posting.goo gle.com...[color=blue]
            > hi
            >
            > I got an XmlNode called xNode
            > Is there a way to convert it so it fits into a string ?[/color]


            Comment

            • Jeppe BS

              #7
              Re: From XmlNode to string


              [color=blue]
              >I'm sure you *can* do that - but whether or not it's the >string you
              >*want* to return, I don't know. What are you passing this >string to
              >afterwards? What format is it expected to be in?[/color]

              Well a want a string so i chekck in it my browser if i find the node i
              am seraching for.

              Guess i could write it into a file, open the file, read like a string,
              and return. But wouldnt that be a long way to fix it ??

              *** Sent via Developersdex http://www.developersdex.com ***
              Don't just participate in USENET...get rewarded for it!

              Comment

              • Jon Skeet [C# MVP]

                #8
                Re: From XmlNode to string

                Jeppe BS <anonymous@devd ex.com> wrote:[color=blue][color=green]
                > >I'm sure you *can* do that - but whether or not it's the >string you
                > >*want* to return, I don't know. What are you passing this >string to
                > >afterwards? What format is it expected to be in?[/color]
                >
                > Well a want a string so i chekck in it my browser if i find the node i
                > am seraching for.[/color]

                Just any string? You could use any of the following properties:

                OuterXml, InnerXml, Value, Name

                (and that's just for starters). Those will each give different strings
                though - if you're not sure which one of them you want, I suggest you
                read the documentation for each of them and see which one sounds most
                useful to you.
                [color=blue]
                > Guess i could write it into a file, open the file, read like a string,
                > and return. But wouldnt that be a long way to fix it ??[/color]

                Yes it would.

                --
                Jon Skeet - <skeet@pobox.co m>
                Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

                If replying to the group, please do not mail me too

                Comment

                Working...