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. Web Development
  3. ASP.NET
  4. Retrieving the value in the embed html

Retrieving the value in the embed html

Scheduled Pinned Locked Moved ASP.NET
csharphtmlasp-netdatabasevisual-studio
8 Posts 3 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.
  • J Offline
    J Offline
    jknascrimz
    wrote on last edited by
    #1

    hi, Iam working with asp.net with c# in VS.Net 2008. And in a task of mine I am fetching a data from the DB which contains a embed html for eg: " <object width="230" height="155"> <param name="movie" value="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="230" height="155"></embed></object>" In this fetched data i need to get only the value="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&" or src="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&" I need only the value or src(i.e) the url Bcoz i need to use that Url for some other purposes also. Kindly help me in getting the value. Thanks in advance.

    K N 2 Replies Last reply
    0
    • J jknascrimz

      hi, Iam working with asp.net with c# in VS.Net 2008. And in a task of mine I am fetching a data from the DB which contains a embed html for eg: " <object width="230" height="155"> <param name="movie" value="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="230" height="155"></embed></object>" In this fetched data i need to get only the value="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&" or src="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&" I need only the value or src(i.e) the url Bcoz i need to use that Url for some other purposes also. Kindly help me in getting the value. Thanks in advance.

      K Offline
      K Offline
      Kannan Ar
      wrote on last edited by
      #2

      Use regular expressions to filter it. Please google for regular expressions patterns that can search url including query strings.

      J 1 Reply Last reply
      0
      • K Kannan Ar

        Use regular expressions to filter it. Please google for regular expressions patterns that can search url including query strings.

        J Offline
        J Offline
        jknascrimz
        wrote on last edited by
        #3

        Thanks For ur Information & I already Googled but not yet derived any suitable solution.

        K 1 Reply Last reply
        0
        • J jknascrimz

          hi, Iam working with asp.net with c# in VS.Net 2008. And in a task of mine I am fetching a data from the DB which contains a embed html for eg: " <object width="230" height="155"> <param name="movie" value="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&"></param> <param name="allowFullScreen" value="true"></param> <param name="allowscriptaccess" value="always"></param> <embed src="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="230" height="155"></embed></object>" In this fetched data i need to get only the value="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&" or src="http://www.youtube.com/v/Ab9kmqBmhXc&hl=en&fs=1&" I need only the value or src(i.e) the url Bcoz i need to use that Url for some other purposes also. Kindly help me in getting the value. Thanks in advance.

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          2 ways to do this. 1) Regular expression 2) Loading the content into XmlDocument and using XPath to query. 2nd method will be easy to implement. Sample XPath query, /object/param[@name='movie'] This will give all param elements which have a name attribute with value movie. From this, you can easily get value of attribute value.

          Navaneeth How to use google | Ask smart questions

          J 1 Reply Last reply
          0
          • N N a v a n e e t h

            2 ways to do this. 1) Regular expression 2) Loading the content into XmlDocument and using XPath to query. 2nd method will be easy to implement. Sample XPath query, /object/param[@name='movie'] This will give all param elements which have a name attribute with value movie. From this, you can easily get value of attribute value.

            Navaneeth How to use google | Ask smart questions

            J Offline
            J Offline
            jknascrimz
            wrote on last edited by
            #5

            Thanks for ur kind reply, I need the solution in the 1st way i.e Using RegularExpression coz am working with C# + asp.net. In the regex, it is possible to find the keyword value or src but what i need is url that follows these value or src. I tried for it but failed to proceed further in getting that specified Url.

            N 1 Reply Last reply
            0
            • J jknascrimz

              Thanks For ur Information & I already Googled but not yet derived any suitable solution.

              K Offline
              K Offline
              Kannan Ar
              wrote on last edited by
              #6

              Check this[^]

              1 Reply Last reply
              0
              • J jknascrimz

                Thanks for ur kind reply, I need the solution in the 1st way i.e Using RegularExpression coz am working with C# + asp.net. In the regex, it is possible to find the keyword value or src but what i need is url that follows these value or src. I tried for it but failed to proceed further in getting that specified Url.

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                Try this.

                bool TryGetVideoUrl(string input, out string url)
                {
                url = string.Empty;
                string pattern = "embed.src=\"(?<video>[^\"]*)\"";
                Match match = Regex.Match(input, pattern, RegexOptions.IgnoreCase);
                if (match != null)
                {
                url = match.Groups["video"].Value;
                return true;
                }
                else
                return false;
                }

                Use it like,

                string url;
                if (TryGetVideoUrl(input, out url))
                {
                // you got the url. It will be in variable url
                }
                else
                {
                // not found
                }

                :)

                Navaneeth How to use google | Ask smart questions

                J 1 Reply Last reply
                0
                • N N a v a n e e t h

                  Try this.

                  bool TryGetVideoUrl(string input, out string url)
                  {
                  url = string.Empty;
                  string pattern = "embed.src=\"(?<video>[^\"]*)\"";
                  Match match = Regex.Match(input, pattern, RegexOptions.IgnoreCase);
                  if (match != null)
                  {
                  url = match.Groups["video"].Value;
                  return true;
                  }
                  else
                  return false;
                  }

                  Use it like,

                  string url;
                  if (TryGetVideoUrl(input, out url))
                  {
                  // you got the url. It will be in variable url
                  }
                  else
                  {
                  // not found
                  }

                  :)

                  Navaneeth How to use google | Ask smart questions

                  J Offline
                  J Offline
                  jknascrimz
                  wrote on last edited by
                  #8

                  Thank You, I have rated this reponse to the most. thanks one again..

                  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