w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to fetch attribute value under elements/elements in xml using LINQ
To get the value attribute you can use the following: var foo = (from n in xml.Descendants("property") where n.Attribute("name").Value == "TestcaseId" select n.Attribute("value").Value).FirstOrDefault(); Gives: 70592

Categories : C#

extract elements from list of lists with variable number of elements and NAs R
So this can be marked as answered: SimonO101's solution (checking for NA values): lapply(mytestlist, function(x) { if( all(is.na(x)) ){ c(a=0,b=1,c=0) } else { x$nums } }) My solution (checking for named list elements): lapply(mytestlist, function(x) { if('nums' %in% names(x)) { x$nums } else { c(a=0, b=1, c=0) } })

Categories : R

How to get text from a
This will get exactly what you want: address = soup.find('div', {'style':'float:left;width:100%;padding-top:10px;padding-bottom:30px;'}) print address.get_text() use a dict to define the style attr use get_text() to get text between tags

Categories : Python

Number of sets for which there exists a unique subset for all number from 1 to n such that sum of elements of subset is equal to the number
Think of a N by N matrix where each element counts up to N. Build this matrix with 2 loops. Then each row that sums to N is a solution. When N = 5 build: 0 0 0 0 0 0 0 0 0 1 0 0 0 0 2 0 0 0 0 3 0 0 0 0 4 0 0 0 0 5 SOLUTION 0 0 0 1 1 0 0 0 1 2 0 0 0 1 3 0 0 0 1 4 SOLUTION 0 0 1 0 1 etc.

Categories : Misc

How to add elements from sublists with 2 elements (the first element is a string and the second one a number)?
You just need to break out the string versus the number: sum_fire( [[_,N]|Tail], Sum ) :- sum_fire( Tail, S1 ), Sum is N + S1. sum_fire( [], 0 ). So I'm using [_,N] instead of H for the head item because I want what's inside (the number N). I don't care about the string for the sum, so it's _.

Categories : Prolog

Use xsl:number and match the substring of current element's attribute with the first instance of preceding sibling attribute substring?
My first impressions are: (a) this is probably beyond the capability of xsl:number (b) the reason your xsl:number pattern isn't working is that within a pattern, current() refers to the node being matched against the pattern, whereas I think your code is assuming that it matches the node being numbered. I would tackle this as a grouping problem (using <xsl:for-each-group group-adjacent= "@pages/substring(., 1, 5)">; you can use <xsl:number value="position()" format="a"> to get and format the number representing the position of a bookDocument within its group.

Categories : Xml

Find div with style attribute jquery
Use an attribute selector: $('div[style]') However, using this to find an element with a specific style (CSS rule) is a bad idea. It will only work for inline styles actually set using style="whatever" and your attribute value in the selector (div[style="whatever"]) would have to match the attribute exactly. So... the proper way to do it is to add a class attribute to the relevant elements and select them using this class (div.whatever for class="whatever" or class="foo whatever bar"). If you still need to find elements with a certain CSS rule the most reliable way would be to iterate over all of them and check if they have the given style: $('div').filter(function() { return $(this).css('whatever') == 'the_value'; });

Categories : Jquery

Add CSS attribute to certain span that contain a CSS style using JavaScript
Give class or id to those elements. .spanOne{ display: none; } or create those elements dynamically and store them in variables. Then you can use those variables to add or remove properties. var spanOne = //code to create span element; var spanTwo = //code to create another span element; $(spanOne).hide(); or $('#parentElementID').children('span').eq(0).hide(); UPDATED: $('div').children('span').filter(function () { return this.style.fontSize == "17.7px"; //in your case 1.7px }).eq(0).css('backgroundColor', 'red'); PS: I recommend adding a class name or id to that element.

Categories : Javascript

JQuery printThis and Style attribute
Instead of touch css attributes directly, add a .myStyle class in your stylesheet with those css properties, and later call .addClass('myStyle') or .removeClass('myStyle') from your function, I think printthis.js imports your local css files. My english is terrible sorry, hope you understand the concept

Categories : Javascript

How do I set an attribute on a many-to-many relationship code first-style?
What you are trying to achieve is called a many to many relationship with attributes. In order to model N to M relationships in a relational database you will always need an intermediate table. To add the attribute with EF, you need another entity to model the relationship and map it properly. In this question it is explained how to do it: Entity Framework Code 1st - Mapping many-to-many with extra info

Categories : C#

Can I style the alt attribute of an image tag in jquery?
Try to find out how the function works, that will save you lots of time in the future. I see you've got more questions about the very same function, which all wouldn't have been necessary if you already knew how it worked. (Sorry, in case you didn't realise, that was tongue in cheek. Because the same thing is true for every other question here on StackOverflow!) Anyway, the trick is to make the outer div position:relative so that the inner divs are positioned in the same spot. Then all you need to do is put them in the middle, for instance by setting the line-height to the same value as the height of the image. And with absolute positioning, you won't need the z-index. Resulting fiddle here

Categories : Jquery

Selecting style attribute with REGEX in PHP
You have it almost correct, you just need to capture the part you want, by surrounding it in parenthesis. You're currently capturing the wrong part: $img = '<img src="test.png" style="float:left;"/>'; preg_match('/<[^>]+ (style=".*?")/i', $img, $match); $result = $match[1]; Demo Note: This will work for simple inputs like the example <img> tag, but for anything more complex Regex is not powerful enough to parse HTML, since HTML is not a regular language. If you find that it's not powerful enough you can use DOMDocument, which is meant for this sort of thing.

Categories : PHP

XML Scheme: Complex type using any number of elements any number of times
It is the <xsd:choice> that must be unbounded here. You correct schema should look like this: <xsd:element name="foo"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> <xsd:element ref="p"/> <xsd:element ref="f"/> <xsd:element ref="summary"/> </xsd:choice> <xsd:attribute ref="type"/> </xsd:complexType> </xsd:element> Setting maxOccurs="unbounded" by each element (p, f, summary) won't make any difference here. It just allows you to repeat the same element many times, but not mix with others.

Categories : Xml

mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables
The characters in the string should not be separated by commas: $stmt->bind_param("sss...", /* variables */); You can see this format demonstrated in the examples on the manual page.

Categories : Mysql

How do you change the style attribute on a TreeGrid PropertyColumn?
You can try to override the PropertyColumn method getCellCssClass(), something like that: PropertyColumn column = new PropertyColumn( columnId,new Model<String>( columnName ), somePropertyExpression, sortProperty ) { @SuppressWarnings("rawtypes") @Override public String getCellCssClass( IModel rowModel, int rowNum ) { if( getId().equals( "testid" ) ) { return "testCell"; } else if( getId().equals( "blablaId" ) ) { return "blablaCell"; } else { return null; } } };

Categories : Java

Why does jQuery 2.0.2 add empty style attribute to body
While this doesn't actually affect anything it's still a valid question. The reason is this code: // Workaround failing boxSizing test due to offsetWidth returning wrong value // with some non-1 values of body zoom, ticket #13543 jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() { support.boxSizing = div.offsetWidth === 4; }); This is just a test for boxSizing support. jQuery.swap() is described in the source as: A method for quickly swapping in/out CSS properties to get correct calculations. body.style.zoom != null ? { zoom: 1 } : {} returns zoom: 1 if body.style.zoom is not null and an empty object if it is. The returned value is then applied to the body element which is why it has an empty style tag.

Categories : Jquery

How to get a style attribute from a CSS class by javascript/jQuery?
How about this? $('<span class="highlight"></span>').appendTo('body'); $(this).animate({ color: $('.highlight').css('color') }, 750); $('.highlight').remove(); It's kind of dirty but will give you an (empty) element to reference to get the CSS value for which you are looking. Update Here is a decent solution from CSS parser/abstracter? How to convert stylesheet into object function findColorProperty(selector) { rules = document.styleSheets[0].cssRules for(i in rules) { //if(rules[i].selectorText==selector) //return rules[i].cssText; // Original if(rules[i].selectorText == selector) return rules[i].style.color; // Get color property specifically } return false; } Usage $(this).animate({ color: findColorPro

Categories : Javascript

Is there a limitation when applying the style via the class attribute in javascript?
You should be using className and not class. lbl.className = 'label'; Modern Day browsers support classList lbl.classList.add("label");

Categories : Javascript

How to remove the style attribute from li tag nested within two divs via Jquery
Simply you can do $("li").removeAttr("style"); //removes all li style attributes. If li in a div $('.garage li').removeAttr("style"); // remove specifically inside a div.

Categories : Jquery

Reason why style attribute does not use the android: namespace prefix
From the documentation: Note: The style attribute does not use the android: namespace prefix. The reason style doesn't use the android namespace prefix is because it is part of the stock XML attributes.

Categories : Android

retrieve html inline style attribute value with jsoup
You can retrieve the style attribute of the element and then split it by :. Example: final String html = "<th style="text-align:right">4389</th>"; Document doc = Jsoup.parse(html, "", Parser.xmlParser()); // Using the default html parser may remove the style attribute Element th = doc.select("th[style]").first(); String style = th.attr("style"); // You can put those two lines into one String styleValue = style.split(":")[1]; // TODO: Insert a check if a value is set // Output the results System.out.println(th); System.out.println(style); System.out.println(styleValue); Output: <th style="text-align:right">4389</th> text-align:right right

Categories : Java

How to check if HTML style attribute exists with javascript
if(contentWrapper.getAttribute("style")){ if(contentWrapper.getAttribute("style").indexOf("display:") != -1){ alert("Not Empty"); } else { alert("Empty"); } }

Categories : Javascript

Style is only applying to two elements
Because the Style is a StaticResource, I believe only one instance of the Style content will be created, which will then be passed around to be presented to whichever control a Setter is fired on. You should be able to use the 'x:Shared' attribute to create a new instance of your style, rather than sharing the same instance across controls. So, adding 'x:Shared=False' to your first line: <Style x:Key="EstiloToggleButton" TargetType="{x:Type ToggleButton}" BasedOn="{StaticResource {x:Type ToggleButton}}" x:Shared ="False" > <!-- Your code --> Should do the trick. From MSDN: x:Shared Attribute When set to false, modifies WPF resource-retrieval behavior so that requests for the attributed resource create a new instance for each request instead of sharing the same ins

Categories : C#

How do I bind data to a CSS property without using the style attribute of the element in Dart web-ui?
I would suggest thinking about this in a slightly different manner: try applying a CSS class using the Dart syntax <html> <body> <element name='foo' constructor='FooElement' extends='div'> <style> div { display: block; } div.hide { display: none; } </style> <template> <div class="{{isVisible ? '' : 'hide'}}">Foobar</div> </template> <script type="application/dart" src="xfooelement.dart"></script> </element> </body> </html>

Categories : CSS

How to resolve root relative URL in a style attribute for background-image
A separate class in an external stylesheet is cleaner (and the path will be relative to the stylesheet). However, you can use Url.Content('~/images/department/" + Model.DepartmentImage ) inside your view to return the complete, resolved path. Note that this isn't an absolute URL (details), but based on your example syntax you are looking for the URL to be resolved to the application root, regardless of where in the directory hierarchy the URL is output.

Categories : Asp Net Mvc

InDesign CS6 Script to Change Style based on XML Attribute not working
you will want to use the correct xPath Expression to match your paragraphs var subheadElementList = rootElement.evaluateXPathExpression("//*[@class = 'boxtitle']"); or more specific if your paragraphs have the markupTag name "mypara" for Example: var subheadElementList = rootElement.evaluateXPathExpression("//mypara[@class = 'boxtitle']");

Categories : Javascript

CSS selector to check an attribute of a child div and style based on the result?
No, you cannot.. yet. The CSS4 Selectors Spec shows a way to choose the subject of a rule, but it is not implemented in any browsers. To note, hopefully you will be able to do this soon (from the spec) For example, the following selector represents a list item LI unique child of an ordered list OL: OL > LI:only-child However the following one represents an ordered list OL having a unique child, that child being a LI: !OL > LI:only-child

Categories : HTML

Setting a left style CSS attribute to move a slider in Javascript
this is because you do not write the style, you just read it and edit the value itself but not the target.left function move(tag) { var target = document.getElementById(tag).style; var current = target.left; function moveObject () { current = parseInt(current) + 10 + 'px'; console.log(current); target.left = current; // <- setTimeout( moveObject,1000); } setTimeout( moveObject, 1000); }

Categories : Javascript

css: style all a elements befor hovered
Do you want to style all elements differently? you can select elements by nth-child selector. Example: a:nth-child(1){} a:first-child+a{} or a:nth-child(1) + a /* Second Element */ a:last-child{} /*select last child, Works in ie8+, webkit, moz, o */

Categories : CSS

Alter CSS Style for Elements Within a Link
You an do this very simply by applying a pseudo-selector to the parent element and include the children after it. Like this: a:hover h2 { <properties on parent hover> } a:hover div { <properties on parent hover>} Attention: In your code you used <div id="cellicon">. From the name, this sounds like a class. Just don't forget you break HTML if you re-use the same ID. You could also include all your icons in one sprite, for every link; suppose you have 5 icons (16x16px) with different properties for :hover, :active and :visited . Your sprite will have 4 images for each icon. Code for every icon will be: (values from icon 2) a div { /* first specify the sprite for all links */ background-image: url('...'); } a#<linkid> div { /* normal state */ background-posi

Categories : HTML

Change style of all elements using getElementsByTagName()
You're using the HTML5 hidden attribute, so you should just reverse that property. for (var i = 0; i<elems.length; i++) { elems[i].hidden = !elems[i].hidden; } DEMO: http://jsfiddle.net/TEXJp/ If you were to use the style object, then you need to consider that it will only report styles that were set directly on the element. So your test should be for == "" instead of == "visible", or for == "hidden" if you actually set it on the original elements. <span style="visibility:hidden;">H</span> <span>V</span> <span style="visibility:hidden;">H</span> <span>V</span> var elems = document.getElementsByTagName('span'); for (var i = 0; i < elems.length; i++) { if (elems[i].style.visibility === "hidden") { elems[i].

Categories : Javascript

Disable all style attributes for all elements
There are two separate things - indent plugin should be able to indet only lists (changing their structure, not adding left margin), not blocks. At this moment one plugin does two jobs, what does not make sense. Patch for this will be released in about a month - https://dev.ckeditor.com/ticket/10027. Although, even now it is possible to configure indent to use classes rather than styles - see the config.indentClasses option.

Categories : Javascript

Applying same style to multiple elements
You could use FrameworkElement as a TargetType: <Style TargetType="FrameworkElement" x:Key="CommonStyle"> <Setter Property="Control.Background"> <Setter.Value> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" > <GradientStop Color="#FFFFD190" Offset="0.2"/> <GradientStop Color="Orange" Offset="0.85"/> <GradientStop Color="#FFFFD190" Offset="1"/> </LinearGradientBrush> </Setter.Value> </Setter> </Style> And then use specific styles for each element by inheriting (BasedOn) CommonStyle: <Style TergetType="TextBox" BasedOn="{StaticResource CommonStyle}" x:Key="TextBoxStyle"> <Setter Property="Margin" Value="2"/&g

Categories : Wpf

Removing elements in a functional style
It seems that you're describing multiset (bag) and its operations. If you use the appropriate data structures, operations are very easy to implement: // Assume that X, Y are initialized bags let matches = X.IntersectWith(Y) let x = X.Difference(Y) let y = Y.Difference(X) There's no built-in Bag collection in .NET framework. You could use Power Collection library including Bag class where the above function signature is taken. UPDATE: You can represent a bag by a weakly ascending list. Here is an improved version of @kqr's answer in F# syntax: let overlap xs ys = let rec loop (matches, ins, outs) xs ys = match xs, ys with // found a match | x::xs', y::ys' when x = y -> loop (x::matches, ins, outs) xs' ys' // `x` is smaller than every element in

Categories : Algorithm

Style to dynamically created elements
Just write it in some other function function somefunctiontoloadmoreitems() { $('.divlink').attr('href','www.facebook.com'); } Tell if this you wanted? I am not sure. function appendvalues(href, classname) { var maindiv = document.getElementById("maindiv").childNodes; for(var i=0; i<maindiv.length; i++) { maindiv[i].setAttribute("href",href); maindiv[i].setAttribute("class",classname); } } Try to implement this in your code.

Categories : Jquery

Use of tab-size style (CSS) attribute seems to be being ignored - could be a browser bug, want to check before informing mailing list
Please check the MDN documentation on the tab-size property. It is still an experimental property and as such you need to add vendor prefixes to make it work in some browsers. Chrome accepts plain old tab-size without a vendor prefix, but to add Firefox and Opera support you will need to do the following: tab-size:4; -moz-tab-size:4; -o-tab-size:4;

Categories : HTML

How to remove all elements inside