i want to extract the
iframe tag "src" value from the below url
http://www.teluguone.com/videos/single/comedy/Comedy-Express-464---Back-to-Back---Comedy-Scenes-14727.html
iframe width="640" height="380" src="http://www.youtube.com/embed/XJDw2T1nGJQ"frameborder="0"
allowfullscreen/iframe
How can i achieve it in j2me?htmlparser ,Jericho ,Jsoup parser are not supported in j2me
Assuming you already have the html source stored in a String variable called htmlPage.
int iFrameIndex = htmlPage.indexOf("iframe");
int srcIndex = htmlPage.indexOf("src", iFrameIndex);
int httpIndex = htmlPage.indexOf("http", srcIndex);
int quotesIndex = htmlPage.indexOf("\"", httpIndex);
String srcUrl = htmlPage.substring(httpIndex, quotesIndex);
Related
I've been working on a azure project, and I want to create a dataflow using a dynamic filename that contains timestamp.
for example , if the output is a file name 'A' --> 'A_YY-mm-dd_hh_mm_ss'
I already did that on a data factory using this link Here
but in this case I don't know how could I use it.
there is my data flow
The input is an extract file( i did it with a copy data)
You can refer this code. I tried to modify the filenamePrefixForWindow method and I was able to achieve this. These were the changes I made -
public String filenamePrefixForWindow(IntervalWindow window) {
Calendar calendar = Calendar.getInstance();
String year = String.valueOf(calendar.get(Calendar.YEAR));
String month = String.format("%02d",(calendar.get(Calendar.MONTH)+1));
String date = String.format("%02d",calendar.get(Calendar.DATE));
int hh = calendar.get(Calendar.HOUR);
String hour = String.format("%02d",(calendar.get(Calendar.AM_PM) == 0) ? hh:hh+12);
String minute = String.format("%02d",calendar.get(Calendar.MINUTE));
String full_date = year+"-"+month+"-"+date+"-"+hour+"-"+minute;
String prefix =
baseFilename.isDirectory() ? "" : baseFilename.getFilename();
return String.format(
"%s/%s/%s/%s/%s/output-%s", prefix,year,month,date,hour,full_date);
}
With Couchbase's jsonObject we can create object with certain fields:
import com.couchbase.client.java.document.json.JsonObject
...
JsonObject content = JsonObject.create().put("some", "value");
The put function has several String & value options such as double, int, String etc, as can be seen here.
I was looking for a way to put a whole object in it. Something like:
Cat cat = new Cat(.....)
JsonObject content = JsonObject.create().put(cat);
Is there a way to do it and not to iterate over all of Cat's fields?
So here is how it can be done:
Cat cat = new Cat(...);
String asJson = gson.toJson(cat);
JsonObject.fromJson(asJson);
Please help, I am trying to pass a string that exists in a variable I created. It is todo with weather info I am grabbing with an API. This is the variable I am creating;
success : function(parsed_json) {
var temp_f = parsed_json['current_observation']['temp_f'];
var wind_kph = parsed_json['current_observation']['wind_kph'];
var wind_gust_kph = parsed_json['current_observation']['wind_gust_kph'];
var wind_string = parsed_json['current_observation']['wind_string'];
alert(wind_string);
gauge3 = wind_gust_kph
gauge4 = wind_kph
The alert works and prints my string. Now I want to pass it into a
<td><div><marquee behavior="scroll" direction="left">("wind_string")</marquee></div></td>
I have tried many options and can only get what I type and not the actually string inside the variable.
Hope that is clear!
Add an id - "wind", as you suggested - to the marquee element to make it more searchable:
<marquee id="wind" behavior="scroll" direction="left"></marquee>
Get the marquee element with getElementById and assign the string you want to its innerHTML:
var wind_string = parsed_json['current_observation']['wind_string'];
//alert(wind_string);
document.getElementById('wind').innerHTML = wind_string;
Note: the marquee element became obsolete in HTML5.
We have a compound CT, which outputs the code field of one of the component.
The dream-weaver part of CT is as follows:
<!-- TemplateBeginRepeat name="Component.HTMLCode" -->
##Component.HTMLCode##
<!-- TemplateEndRepeat -->
However this CT displays the code field on the page, instead of converting into HTML.
For eg: If the code field has a value as ->
<div align="center" id="loginapp"></div>
Then this same value is displayed on page instead of parsing.
In the page source, we get output as "< ;div align=" ;center" id=" ;loginapp" ;> ;< ;/div> ;"
I know this can be resolved if we use C#.
But is there any way using dreamweaver to stop the conversion of special characters?
You should use dwt to publish the code to server, I mean create new dwt for every code and just paste the code in the dwt. you can use this dwt with emply component or resource type component.
or if you want to use text field, try following tbb code. add this tbb at the end of the template.
public override void Transform(Engine engine, Package package)
{
Regex objExp = new Regex(#"&#\d+;", RegexOptions.IgnoreCase);
Regex objDecExp = new Regex(#"[^0-9]", RegexOptions.IgnoreCase);
this.Initialize(engine, package);
string strPackage = package.GetValue("Output");
strPackage = unescapeHTML(strPackage);
strPackage = objExp.Replace(strPackage, delegate (Match match)
{
string strInput = match.ToString();
strInput = objDecExp.Replace(strInput, "");
int intValue = Convert.ToInt32(strInput);
char strChar = (char)intValue;
return strChar.ToString();
});
strPackage = strPackage.Trim();
Item objOutput = package.CreateStringItem(ContentType.Html, strPackage);
package.PushItem("Output", objOutput);
}
private string unescapeHTML(string strInput)
{
StringBuilder strOutput = new StringBuilder(strInput);
strOutput.Replace(""", """);
strOutput.Replace(" ", " ");
strOutput.Replace("&", "&");
strOutput.Replace("'", "'");
strOutput.Replace("<", "<");
strOutput.Replace(">", ">");
strOutput.Replace("¡", "¡");
strOutput.Replace("¢", "¢");
strOutput.Replace("£", "£");
strOutput.Replace("¤", "¤");
strOutput.Replace("¥", "¥");
strOutput.Replace("¦", "¦");
strOutput.Replace("§", "§");
strOutput.Replace("¨", "¨");
strOutput.Replace("©", "©");
strOutput.Replace("ª", "ª");
strOutput.Replace("¬", "¬");
strOutput.Replace("", "­");
strOutput.Replace("®", "®");
strOutput.Replace("¯", "¯");
strOutput.Replace("°", "°");
return strOutput.ToString();
}
}
If I recall correctly it is depending on your fieldtype, if in your Schema you use a normal text field, then HTML is escaped, if you use a rich text field, it will be resolved.
An option would perhaps be to write a Dreamweaver Custom function which allows you to unescape the field (represent it as an HTML field rather than a text field). As you mentioned you could also do it in a TBB, but the Dreamweaver Custom Functions are directly callable from the DWT Template. Either way I think you indeed need to do some coding yourself.
RenderComponentField has two parameters: bool htmlEncodeResult, and bool resolveHtmlAsRTFContent. Are you using this built in function?
Thanks for your help. After lots of trials with dreamweaver code, we decided to use C# TBB instead which solved the purpose.
Also reading the multiline field as a textfield was one of the mistake we committed. This caused the field value to be displayed on page instead of rendering as a code behind.
We finally solved the issue using "MultilineTextField".
Problem
As we know, SharePoint saves data in database in plain text. Some fields even have concatenated strings like <id>;#<value> for user fields. Percents are saved as doubles (1.00000000000000 for 100%) and etc.
Ofcourse, I want to display data as they are displayed in lists.
What should I do?
Should I use derived SPBoundField to format values (Which I actually did and it works fine until you want to filter (probably SPBoundField won't format me values because i use ObjectDataSource not list and with reflector I saw if there are SPListItems in datasource, then it formats correctly. Not my case)
alt text http://img199.imageshack.us/img199/2797/ss20090820110331.png
Or must I loop through all the DataTable and format each row accordingly?
What are Your techniques?
Thank you.
Here is how I solved this issue.
<asp:TemplateField HeaderText="Campaign Members">
<ItemTemplate>
<%# RemoveCharacters(Eval("CampaignMembers").ToString())%>
</ItemTemplate>
</asp:TemplateField>
// Make sure declare using System.Text.RegularExpression;
protected string RemoveCharacters(object String)
{
string s1 = String.ToString();
string newString = Regex.Replace(s1, #"#[\d-];", string.Empty);
newString = Regex.Replace(newString, "#", " ");
return newString.ToString();
}
I normaly use ItemTemplates that inherit from ITemplate. With in the ItemTemplate I use the SPFieldxxxValue classes or some custom formating code. This saves looping through the DataTable and the ItemTemplates can be reused.
The ItemTemplates are attached in Column Binding
E.G
// Normal Data Binding
SPBoundField fld = new SPBoundField();
fld.HeaderText = field.DisplayName;
fld.DataField = field.InternalName;
fld.SortExpression = field.InternalName;
grid.Columns.Add(fld);
// ItemTemplate Binding
TemplateField fld = new TemplateField();
fld.HeaderText = field.DisplayName;
fld.ItemTemplate = new CustomItemTemplateClass(field.InternalName);
fld.SortExpression = field.InternalName;
grid.Columns.Add(fld);
An example of a ItemTemplate
public class CustomItemTemplateClass : ITemplate
{
private string FieldName
{ get; set; }
public CustomItemTemplateClass(string fieldName, string formatString)
{
FieldName = fieldName;
}
#region ITemplate Members
public void InstantiateIn(Control container)
{
Literal lit = new Literal();
lit.DataBinding += new EventHandler(lit_DataBinding);
container.Controls.Add(lit);
}
#endregion
void lit_DataBinding(object sender, EventArgs e)
{
Literal lit = (Literal)sender;
SPGridViewRow container = (SPGridViewRow)lit.NamingContainer;
string fieldValue = ((DataRowView)container.DataItem)[FieldName].ToString();
//Prosses Filed value here
SPFieldLookupValue lookupValue = new SPFieldLookupValue(fieldValue);
//Display new value
lit.Text = lookupValue.LookupValue;
}
}
Here are a few options. I don't know the output of all of them (would be a good blog post) but one of them should do what you want:
SPListItem.GetFormattedValue()
SPField.GetFieldValue()
SPField.GetFieldValueAsHtml()
SPField.GetFieldValueAsText()
It may also be handy to know that if you ever want to make use of the raw values then have a look at the SPField*XYZ*Value classes. For example the form <id>;#<value> you mention is represented by the class SPFieldUserValue. You can pass the raw text to its constructor and extract the ID, value, and most usefully User very easily.
I would suggest either to format the values before binding them to the spgridview. Linq and an anonymous type is preffered or to call a code behind function on the field that needs the formatting upon binding.
DataField='<%# FormatUserField(Eval("UserFieldName")) %>'
or...maybe a templated field?
After all, i did have not know any other solution to loop through DataTable rows and format them accordingly.
If your SPGridView's data source is list, try out SPBoundField.