w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Find out wheter node exists in xml-document
That's a special node type called processing instruction. You can query it using XPath to find out if it exists and what its attributes are: /processing-instruction('xml-stylesheet')

Categories : Java

AS3 - Find JSON node by content
Try with this code, this will be useful as an example (its works perfectly) (download this library before): <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()"> <mx:Script> <![CDATA[ import mx.utils.ArrayUtil; import mx.controls.Alert; import lib.JSON; private var jsonString:String = '{"root":[{"id":"val1"},{"id":"val2"}]}'; public function init():void{ var decodedObj:Object = JSON.decode(jsonString); Alert.show(decodedObj["root"][0].id); //prints val1 Alert.show(ArrayUtil.toArray(decodedObj["root"])[1].id); //prints val2 } ]]> </mx:Script> </m

Categories : Json

Checking if node exists and adding child node
In which part do you get the error? In the if or in the else? Also, your code could be much simpler: if(comboBox3.Text == "Books") { if (!treeView1.Nodes.ContainsKey("Books")) treeView1.Nodes.Add("Books"); treeView1.Nodes["Books"].Nodes.Add(textBox1.Text); } Edit: When adding a TreeNode, you have to provide a name for the node. Only then can you get a node of the collection by accessing the collection through a name. If you don't set a name, you can still access the collection by using an index. But in this case you're using a string-key, therefore you also have to provide a name for the Books-TreeNode: if(comboBox3.Text == "Books") { if (!treeView1.Nodes.ContainsKey("Books")) { TreeNode booksNode = new TreeNode("Books"); booksNode.Name = "Books";

Categories : C#

File does exists when calling .exists() but can't find it later
The mediaStorageDir.exists() returns true, but I can't find the folder in windows. Probably that is because MediaStore does not know about the directory, and so the MTP connection to Windows does not know about the directory. You can try using MediaScannerConnection and scanFile() to resolve this, though I have only tried that for files, not directories. Also, even after indexing, you may need to do "Refresh" from your Explorer window, or disconnect/reconnect the device, as Windows may cache the MTP results and not detect a change even if Android knows about it.

Categories : Android

Kendo UI treeview find the next node and previous node of the selected node
You should use jQuery next and prev for getting the nodes. You can use: var sel = treeview.select(); var next = $(sel).next(); var prev = $(sel).prev(); Where: treeview is the treeview object (i.e. $("#grid").data("kendoTreeView")) sel is current selected node, next is next node. and prev previous node. If you need to get the item in the model you should use treeview.dataItem with sel, next or prev as argument.

Categories : Kendo Ui

Combining node-mysql result rows into single JSON return for node.js
Asked and answered. The Async.js utility has lots of good stuff including a map function and underscores.js helps tidy anything up! app.get('/viewing/:id', function (req, res){ if(!req.cookies.user) { res.end('Requires Authenticated User'); } else { connection.query('SELECT something,somethingelse from mytable where userId = ?',[req.params.id], function (error, rows, fields) { async.map(rows, getUsers, function(err, results){ res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(JSON.stringify(_.flatten(_.compact(results)))); }); }); } }); function getUsers(user, callback) { connection.query('SELECT id,firstName,lastName FROM users WHERE id = '+ user.otherId, function(err, info) { if(err) { consol

Categories : Javascript

AS3 Flash CC XML need to find the attribute of a node, node number unknown
A couple of things. I think you need to quote the values of your attributes (at least I get an error in Flash CS5 if I don't). Keep an eye on the console for errors to catch this sort of thing. Also, myList is part of the node hierarchy so you need to reference the category node via that. You may be able to do what you want without looping, but I couldn't see a way in the documentation. However, you can definitely get the value you need by looping over the word nodes in the selected category like this: var list:XML = new XML('<xml><mylist><category cat="klank"><word aw="nk">Word</word><word aw="ok">Word2</word><word aw="pk">Word3</word></category></mylist></xml>'); var curWord = 'Word'; var words:XMLList = list.myl

Categories : Xml

CakePHP AclNode::node() - Couldn't find Aro node identified
I had the error because lft and rght columns were null. Missed it in cakephp Automated tool for creating ACOs manual. Solved it by running console script: cake AclExtras.AclExtras recover aro

Categories : PHP

JSon select node based on condition applied on other node?
you can do it this way maybe: var docs=json.response.docs; var max=json.response.numFound; var urls=[]; for(var i=0;i<max;i++){ if(myDateLogicFunc(docs[i].solr_date)) urls[]=docs[i].solr_url[0]; } Your urls wich match your date logic are now stored in the urls array. It's not really more difficult than dom parsing, the "difficulty" is to deal with arrays or objects.

Categories : Java

node.js Amazon s3 how to check file exists
You have to do it the HTTP way with a HEAD request. A file that does not exist triggers a 404 error. Here's a simple implementation: var s3 = require('aws2js').load('s3', process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY) s3.setBucket(process.env.AWS2JS_S3_BUCKET) s3.head(process.argv[2], function (err, res) { if (err) { console.log(err) return } console.log(res) }) For testing purposes, invoke it with: node s3-check.js file/path.foo Examples: node s3-check.js foo1.png { 'x-amz-id-2': 'BU8rLC35oZdNLh4TkE9Y5+czR5r9hg7kl/EbhkxUF+cA94F41knI2YNs/YG1acQg', 'x-amz-request-id': '7714B364EC1A27B2', date: 'Mon, 17 Jun 2013 06:42:52 GMT', 'last-modified': 'Tue, 28 May 2013 13:18:12 GMT', etag: '"2830931876c37237ae98458a99e86d85"', 'accep

Categories : Node Js

Laravel 4/SimpleXML/PHP node no longer exists
Ah, I see your problem; your trying to get the attributes (maxlevel etc) from the first child-element, which is <config>, and that elements has only a 'enabled' attribute. Try this; <?php $xml = '<stages> <config enabled="0"/> <stage minlevel="1" maxlevel="8" multiplier="7"/> <stage minlevel="9" maxlevel="20" multiplier="6"/> <stage minlevel="21" maxlevel="50" multiplier="5"/> <stage minlevel="51" maxlevel="100" multiplier="4"/> <stage minlevel="101" multiplier="5"/> </stages>'; $list = simplexml_load_string($xml); echo "<pre>"; foreach($list->children() as $child) { switch($child->getName()) { case 'config': echo 'Config->enabled: '; echo (string)$child['enabled'];

Categories : PHP

Can't create node with properties here. It already exists in this context
This looks like it is because you have already bound to the identifier "referee" in the START portion of the query. You should not need the START referee=... in your query because CREATE UNIQUE will find it by the properties supplied, or create it.

Categories : PHP

Check whether directory exists "rel1.5" exists in Repository https://xx/svn/MobileApp/Tags if exists do some action else the other
<project name="demo" default="build"> <property name="tag" value="rel1.5"/> <condition property="url.exists"> <http url=" https://www.exampledomain.com/svn/MobileApp/Tags/${tag}" errorsBeginAt="401"/> </condition> <target name="check1" if="url.exists"> <echo message="URL exists"/> </target> <target name="check2" unless="url.exists"> <echo message="URL does not exist"/> </target> <target name="build" depends="check1,check2"> </target> </project>

Categories : Svn

How to check if a schema index already exists for a node's property in neo4j?
why don't you check the Indexes for a Label before trying to create it and getting a (correct) exception? http://api.neo4j.org/2.0.0-M03/org/neo4j/graphdb/schema/Schema.html#getIndexes(org.neo4j.graphdb.Label)

Categories : Java

Node.js Express Jade: Is there a way to define a JSON view for all URLs that (say) end with ".json"?
If it is just for debugging purpose then you could make a middleware that would override render method to json. I will not recommend to use this in production. In your app.configure add this: app.use(function(req, res, next) { if (req.query.json !== undefined) { res.render = function(name, data) { res.json(data); } } return next(); }); So what it does: if request has json in query, then it will override render method and will call json instead. So test it with: http://example.com/test?json

Categories : Node Js

Where to find out if a function exists?
Well, you're trying to use a PhP function into a SQL query... it can't work ! Here's a bit of explanation on how to use the function in PhP : http://www.w3schools.com/php/func_mysqli_insert_id.asp

Categories : PHP

How to check if a json key exists?
use optString instead of getString: Returns the value mapped by name if it exists, coercing it if necessary. Returns the empty string if no such mapping exists

Categories : Java

ConcurrentDictionary fails to find a key even if I am sure it exists
If you're writing bytes to a network stream and then reading them back, you have to either precede the data with a value that says how many bytes follow, or you need an end-of-data marker. The way your code is written, it's quite possible that the receive code is only picking up part of the data. Imagine, for example, that your key is "HelloWorld". Your send code sends the string out. The receive code sees the "Hello" part in the buffer, grabs it, checks to see if more data is available, and it's not because the network transport thread hasn't finished copying it to the buffer. So you get only part of the string. Another thing that can happen is that you read too much. That can happen if you write two strings out to the network stream and your reader reads both of them as if they're a s

Categories : C#

Using EXISTS to find rows with Maximum value
Because you have told to DBMS get all rows where age is lower than maximum age of a person. You obtain row for Jim 20 and Jim 21. If you want the max age about every person, you must: SELECT distinct Name, Age FROM #B A WHERE not EXISTS ( SELECT 1 FROM #B B WHERE A.Age < B.Age AND A.NAME = B.NAME ) I've added a NOT before EXISTS. Remain DISTINCT because you have 2 rows (Jim, 21) with the same age

Categories : SQL

Find If Value Exists on other Worksheet (Excel)
A very easy way is to declare the range that you want to search in and the value that you want to find. Sub findValue() Dim xlRange As Range Dim xlCell As Range Dim xlSheet As Worksheet Dim valueToFind valueToFind = "MyValue" Set xlSheet = ActiveWorkbook.Worksheets("Sheet2") Set xlRange = xlSheet.Range("B1:B10") For Each xlCell In xlRange If xlCell.Value = valueToFind Then 'Do Something End If Next xlCell End Sub I'm assuming that your range of ("A5:B5") is a merged cell because you indicated that it contained a single value. Merged cells can just be referenced by the "top left" cell within the merge (or at least that's how I think of it). So your merged range of ("A5:B5") can be referred to as just ("A5"). Anyway, her

Categories : Excel

How to find out if the caret exists [in opera]?
You're probably out of luck. However, if Opera uses the system caret (which it might not; IE doesn't, for example), you can try using MSAA to query the system caret location: IAccessible *pAccCaret = NULL; VARIANT varCaret; RECT rcCaret; varCaret.vt = VT_I4; varCaret.lVal = CHILDID_SELF; if (SUCCEEDED(AccessibleObjectFromWindow(hwnd, OBJID_CARET, IID_IAccessible, (void **)&pAccCaret))) { hr = pAccCaret->accLocation( &rcCaret.left, &rcCaret.top, &rcCaret.right, &rcCaret.bottom, varCaret); pAccCaret->Release(); }

Categories : C#

Find if selector exists in variable
Supposing data is some HTML, use $(data).find("#myid").length or this more reliable solution if your document isn't well formed : $("<div>").html(data).find("#myid")

Categories : Javascript

Unbind can't find model that clearly exists
It's normal that it can't find the model if you don't tell the association to look for the model in the plugin it belong to. This is not an issue of the plugin but your associations. 'hasOne' => array( 'Tagged' => array( 'className' => 'Tags.Tagged', 'foreignKey' => false, See the plugin name prefix of the className. Same for the Tag model. See the book.

Categories : PHP

Each loop to find if function exists?
In this case the only one that should trigger is 'aa' as function 'aa exists. $.each() is iterating members of the Object passed to it. And, currently, the function aa is not a member of the Object a.b. $.isFunction() isn't returning true because every member of a.b has a String value: aa: 'hello', bb: 'you', cc: 'guys' If you want the function as a member of the Object, you'll need to set it as the value of one of its properties: a.b.aa = function () { var dude = 'hi there'; }; This will replace the 'hello' value with a reference to the function. To reuse the property names to lookup globals, you can use them on the global object (window in browsers). var key = 'aa'; var val = window[key]; var b = function () { $.each(a.b, function (key) { if (key in wind

Categories : Javascript

Find value or check if value exists in object
You're checking for an integer, when the array contains only strings. Also be advised that jQuery's inArray() function does not act like its PHP counterpart. Rather than returning true or false, it returns the actual zero-based index of the value if found (as an integer), or -1 if it isn't in the array. Try this: if($.inArray('1', myObject) >= 0) { // Do your stuff. } Here's a jsFiddle demo

Categories : Javascript

Find elements which exists in the most of the lists
How about: >>> from collections import Counter >>> s = [[1,2,3],[1,5,7],[1,9,3],[4,3,8]] >>> count = Counter(term for subseq in s for term in set(subseq)) >>> [k for k,v in count.items() if v > len(s)//2] [1, 3] Counter is a handy tool which, well, counts things: >>> Counter([1,2,3,3,2]) Counter({2: 2, 3: 2, 1: 1}) [.. oops, just noticed you're using Python 3, so we need .items()].

Categories : Python

check if value exists in json array
The elements of the array are objects, not strings. The values you want to check are the pathway_action_fk properties of those objects. So you have to drill down before checking. if ($.inArray('1', returnedData.map(function(x) { return x.pathway_action_fk; })) != -1); Also, you need to compare the result of $.inArray with -1 -- it returns the found element's index, which can be 0, not a boolean.

Categories : Json

Check if json array exists c#
Your missing the double "==" to check for comparison, "=" is an assignment operation. if(jsonObject.Address == null) { return "null array"; } Your JSON should look like this. Otherwise your not checking for a null array but instead an array with a null value for the first element of the array. { "Name": "Mike", "Personaldetails": [ { "Age": 25, "Surname": "Barnes" } ], "Address": null } Then the code would be the following: if(jsonObject.Address == null) { return "null array"; } If you need to keep the original JSON you can always do a check like so: if(jsonObject.Address.Length > 0 && jsonObject.Address[0] == null) { return "null array"; }

Categories : C#

find if a value of Date exists in arraylist of Calendar
List<Calendar> listFeriers = new ArrayList<Calendar>(); I hope you populate listFeriers somewhere. You could just store the time in millis (getTimeInMillis) in the list rather than creating too many Calendar objects. You can use set to avoid duplicate time entries. Set<Long> listFeriers = new HashSet<Long>(); if(listFeriers.contains(startCal.getTimeInMillis())){ // A match.. }

Categories : Java

Find out whether a whole folder structure exists (CMD Batch)
Wouldn't for /L %%a in (1,1,6) do md Folder%%a be easier, and create the directories whether or not they already exist? for /L %%a in (1,1,6) do md Folder%%a 2>nul should suppress messages for already-existing directories.

Categories : Windows

How to find out if a directory exists on Delphi XE2 *correctly*?
You can just fix your function so that it doesn't cause range check errors: function DirExists(Name: string): Boolean; var Code: DWORD; begin Code := GetFileAttributes(PChar(Name)); Result := (Code <> INVALID_FILE_ATTRIBUTES) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0); end; The range check errors are due to you mixing signed and unsigned types. Remy also points out the very useful trick to set compiler options and then restore to the prevailing state. That's a good trick to learn, but you don't need it here. The XE3 implementation of DirectoryExists is modified to address the problem that you have encountered. So, if using XE3+ was an option, you should take it. To suppress the system error dialogs call this at process startup: procedure SetProcessErrorMode

Categories : Delphi

why a collection exists but can not find in show collections?
Any collection virtually exists all the time (i.e. you will not get an error saying that "you did not create a collection"). As soon as you insert the first document into a collection this will exist also physically (will be created on the disk). So if you really want to make sure a collection exists use: db.getCollectionNames() This will show you only the collections that had at least one document inserted into them, even if they are currently empty. Once physically created, a collection can be deleted using the drop command: db.myColl.drop() This will delete it physically but the "virtual" one will still be there. As for your example, running: db.stat.insert({}); print("Collection stat exists:" + (db.getCollectionNames().indexOf("stat") !== -1)); will tell you: Collection sta

Categories : Mongodb

How to find if url containing special characters or space exists in java
URLs with spaces in them are invalid. The correct way to create a properly encoded URL from a filename that may contain spaces is URI.toASCIIString(), and then passing that to new URL(), making sure to use a URI constructor that takes multiple arguments so the filename part gets encoded: see the Javadoc. However I question the requirement. The best way to test whether any resource is available is to try to use it. In this case presumably you are going to read from the URL if it exists, so just do that and catch the FileNotFoundException.

Categories : Java

Excel 2010 VBA: find out if formatting style exists
This should work : 'case sensitive Private Function checkStyleName(ByVal strStyleName As String) As Boolean Dim sCheck As String Dim wkb As Workbook checkStyleName = False Set wkb = ActiveWorkbook sCheck = "x" & strStyleName ' makes the two strings different On Error Resume Next sCheck = wkb.Styles(strStyleName).Name On Error GoTo 0 If sCheck = strStyleName Then checkStyleName = True End Function

Categories : Vba

Java - Unable to find a file path which certainly exists
In java, and generally most programming languages, you don't always have to provide the exact directory of your file. Although it would be nice to see the code you're using to get the file, I'll provide how it can be done. I'm assuming you aren't using new File("file.txt") because that retrieves files from the folder your program is in, and doesn't require an entire address like C:.......... You certainly don't want to use an entire address because different operating systems use different paths, obviously. The best you can do is put your files and requested folders somewhere relative to your program is (whether it's class files or a .jar file). But with Windows you can be sure that with System.getProperty("...") you can retrieve directory URLs as relative paths for your files/folders.

Categories : Java

Find if a number exists between a range of numbers specified by a list
Since the timestamps are sorted, you can use bisect for that: In [24]: timestamp_list = [1377091800, 1377093000, 1377094500, 1377095500] In [25]: timestamp_list[bisect.bisect_right(timestamp_list, 1377093100)] Out[25]: 1377094500 (I've converted the strings to integers to keep the code clear.)

Categories : Python

rails console find model's parent if exists
"parent" is for classes only, not instances. So, for class parent vehicle.class.parent If you mean associations instead of class, use reflections vehicle.reflections

Categories : Ruby On Rails

how to find the line number where specific text exists?
Use the enumerate function as it works on anything that is an iterable (which your file is). for line_number, line in enumerate(infile): print line_number, line

Categories : Python

when link is clicked, find if parent with certain child exists jquery
The following will work - only the condition in the if has been changed: $('.delete-me').on('click', function () { var id = $(this).attr("id"); if ($(this).closest(".row-fluid").has("[id^='accord-']").length > 0) { var name = $("#accord-" + id).html(); alert(name); }else{ var name = $("#success-" + id).html(); alert(name); } }); Demo: http://jsfiddle.net/RZPW2/15/ The main problem with your if condition: if($(this).parent(".row-fluid").has("#accord-*")) { ...is that it is always truthy, because the .has() method returns a jQuery object not a boolean, and any object is truthy. Also, the .parent() method only gets the immediate parent element, which in the anchor's case is not the .row-fluid element - use .closest() instead to go up

Categories : Javascript

Find out whether a file newer than a given date/time exists in a directory?
Your problem can be translated into multiple easy subproblems Q: How do I recursively look at each file inside a directory? A: use File::Find. This would look a bit like use File::Find; find sub { return unless -f; if (file_is_newer_than($timestamp)) { do something; }, }, $top_dir; Q: How do I do this for multiple directories? A: Wrap it in a foreach loop, e.g. for my $dir_time (["./foo", 1234567890], ["./bar", 1230987654]) { my ($top_dir, $timestamp) = @$dir_time; # above code } Q: How do I determine if the file is newer? A: stat it for mtime or ctime, then compare result with your timestamp. E.g. use File::Stat; say "$_ is new!" if stat($_)->mtime > $timestamp; Q: I'm only interested whether or not any such files exist at all. How can I short curcuit the

Categories : Perl



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.