Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. string

string

Scheduled Pinned Locked Moved C#
question
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    arkiboys
    wrote on last edited by
    #1

    This is my string below: <ProcessData Process="GetAllData" Result="Success" OutputId="Success" Records="1" User="myUserName" Name="GetAll" ProcessItemId="b2494f34-2ed8-41f5-b889-dbaa4aedb1c9" /> Notice that there is Result="Success". It could be failure or something else too. I would like to get the value of Result from this string above. I am trying with indexof but can not get the value of success. How is this done please? Thanks

    M A J T P 5 Replies Last reply
    0
    • A arkiboys

      This is my string below: <ProcessData Process="GetAllData" Result="Success" OutputId="Success" Records="1" User="myUserName" Name="GetAll" ProcessItemId="b2494f34-2ed8-41f5-b889-dbaa4aedb1c9" /> Notice that there is Result="Success". It could be failure or something else too. I would like to get the value of Result from this string above. I am trying with indexof but can not get the value of success. How is this done please? Thanks

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      Use Regular Expressions

      Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

      A 1 Reply Last reply
      0
      • A arkiboys

        This is my string below: <ProcessData Process="GetAllData" Result="Success" OutputId="Success" Records="1" User="myUserName" Name="GetAll" ProcessItemId="b2494f34-2ed8-41f5-b889-dbaa4aedb1c9" /> Notice that there is Result="Success". It could be failure or something else too. I would like to get the value of Result from this string above. I am trying with indexof but can not get the value of success. How is this done please? Thanks

        A Offline
        A Offline
        Ashfield
        wrote on last edited by
        #3

        Isn't this the same question as you asked under the title "Web service"? Anyway, to take pity on you, here is one way: assuming your string is called input

        int pos = input.IndexOf("Result=")+8;
        int pos2 = input.IndexOf("'",pos);
        string output = input.Substring(pos , pos2 - pos);

        All it takes is a few minutes in debug mode.

        Bob Ashfield Consultants Ltd

        A 1 Reply Last reply
        0
        • A arkiboys

          This is my string below: <ProcessData Process="GetAllData" Result="Success" OutputId="Success" Records="1" User="myUserName" Name="GetAll" ProcessItemId="b2494f34-2ed8-41f5-b889-dbaa4aedb1c9" /> Notice that there is Result="Success". It could be failure or something else too. I would like to get the value of Result from this string above. I am trying with indexof but can not get the value of success. How is this done please? Thanks

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          This is not a string, this is an XmlNode. You read Xml by using the classes in the System.Xml namespace When will people stop treating Xml data as strings instead of the Xml data that it is!

          1 Reply Last reply
          0
          • A arkiboys

            This is my string below: <ProcessData Process="GetAllData" Result="Success" OutputId="Success" Records="1" User="myUserName" Name="GetAll" ProcessItemId="b2494f34-2ed8-41f5-b889-dbaa4aedb1c9" /> Notice that there is Result="Success". It could be failure or something else too. I would like to get the value of Result from this string above. I am trying with indexof but can not get the value of success. How is this done please? Thanks

            T Offline
            T Offline
            Timmy Kokke
            wrote on last edited by
            #5

            The string you are uses does look a lot like XML. You could try using Linq to XML (http://msdn.microsoft.com/en-us/library/bb308960.aspx[^]).

            XElement element = XElement.Parse(YourString);
            string Result = element.Attribute("Result").Value

            Dawn is nature's way of telling you to go to bed.

            1 Reply Last reply
            0
            • A arkiboys

              This is my string below: <ProcessData Process="GetAllData" Result="Success" OutputId="Success" Records="1" User="myUserName" Name="GetAll" ProcessItemId="b2494f34-2ed8-41f5-b889-dbaa4aedb1c9" /> Notice that there is Result="Success". It could be failure or something else too. I would like to get the value of Result from this string above. I am trying with indexof but can not get the value of success. How is this done please? Thanks

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              As this is part of the thread below, you should have continued with that one rather than started off a new one.

              arkiboys wrote:

              I would like to get the value of Result from this string above.

              You have already been told to SelectSingleNode to get this. Well, you can use this to return the OutputId value.

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              1 Reply Last reply
              0
              • M Manas Bhardwaj

                Use Regular Expressions

                Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

                A Offline
                A Offline
                arkiboys
                wrote on last edited by
                #7

                SOLVED.

                1 Reply Last reply
                0
                • A Ashfield

                  Isn't this the same question as you asked under the title "Web service"? Anyway, to take pity on you, here is one way: assuming your string is called input

                  int pos = input.IndexOf("Result=")+8;
                  int pos2 = input.IndexOf("'",pos);
                  string output = input.Substring(pos , pos2 - pos);

                  All it takes is a few minutes in debug mode.

                  Bob Ashfield Consultants Ltd

                  A Offline
                  A Offline
                  arkiboys
                  wrote on last edited by
                  #8

                  Hi, The other question was to do with calling the web service which is now solved. This is to do with pulling the data out of the xml string. Which is now solved too. Thank you

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups