Retrieving the value in the embed html
-
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.
-
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.
-
Use regular expressions to filter it. Please google for regular expressions patterns that can search url including query strings.
Thanks For ur Information & I already Googled but not yet derived any suitable solution.
-
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.
2 ways to do this. 1) Regular expression 2) Loading the content into
XmlDocument
and usingXPath
to query. 2nd method will be easy to implement. Sample XPath query,/object/param[@name='movie']
This will give allparam
elements which have aname
attribute with valuemovie
. From this, you can easily get value of attributevalue
.Navaneeth How to use google | Ask smart questions
-
2 ways to do this. 1) Regular expression 2) Loading the content into
XmlDocument
and usingXPath
to query. 2nd method will be easy to implement. Sample XPath query,/object/param[@name='movie']
This will give allparam
elements which have aname
attribute with valuemovie
. From this, you can easily get value of attributevalue
.Navaneeth How to use google | Ask smart questions
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.
-
Thanks For ur Information & I already Googled but not yet derived any suitable solution.
-
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.
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
-
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
Thank You, I have rated this reponse to the most. thanks one again..