nodes

How to swap DOM child nodes in JavaScript?

我与影子孤独终老i 提交于 2019-11-27 22:42:25
What is the easiest way to swap the order of child nodes? For example I want childNode[3] to be childNode[4] and vice-versa. There is no need for cloning. You can just move one node before the other with this: childNode[4].parentNode.insertBefore(childNode[4], childNode[3]); You get the parent of the node. You then call the insertBefore method on the parent and you pass it the childNode[4] node and tell it you want it inserted before childNode[3]. That will give you the result of swapping their order so 4 will be before 3 when it's done. Reference documentation on insertBefore . Any node that

Running a stored procedure with NodeJS and MSSQL package error

别等时光非礼了梦想. 提交于 2019-11-27 21:35:49
Im trying to get the MSSQL nodejs package to return the results of a stored procedure from Microsoft SQL server using the code below. However the error I get is... [TypeError: Cannot read property 'type' of undefined] I'm not sure I have done the inputs correctly as I couldn't find an example with more than one input anywhere online. Any ideas? exports.executeSqlStoredProd = function (callback) { var conn = new sqlDb.Connection(settings.dbConfig) conn.connect().then(function () { var req = new sqlDb.Request(conn); req.input('ProductEntryID', req.Int, 3299); req.input('LoginEntryID', req.Int, 4

Adjusting the node size in igraph using a matrix

删除回忆录丶 提交于 2019-11-27 18:25:34
问题 I have the following network diagram: set.seed(1410) df<-data.frame( "site.x"=c(rep("a",4),rep("b",4),rep("c",4),rep("d",4)), "site.y"=c(rep(c("e","f","g","h"),4)), "bond.strength"=sample(1:100,16, replace=TRUE)) library(igraph) df<-graph.data.frame(df) V(df)$names <- c("a","b","c","d","e","f","g","h") layOUT<-data.frame(x=c(rep(1,4),rep(2,4)),y=c(4:1,4:1)) E(df)[ bond.strength < 101 ]$color <- "red" E(df)[ bond.strength < 67 ]$color <- "yellow" E(df)[ bond.strength < 34 ]$color <- "green" V

How to replace the text of a node using DOMDocument

半世苍凉 提交于 2019-11-27 14:17:54
This is my code that loads an existing XML file or string into a DOMDocument object: $doc = new DOMDocument(); $doc->formatOutput = true; // the content actually comes from an external file $doc->loadXML('<rss version="2.0"> <channel> <title></title> <description></description> <link></link> </channel> </rss>'); $doc->getElementsByTagName("title")->item(0)->appendChild($doc->createTextNode($titleText)); $doc->getElementsByTagName("description")->item(0)->appendChild($doc->createTextNode($descriptionText)); $doc->getElementsByTagName("link")->item(0)->appendChild($doc->createTextNode($linkText)

How to delete/create databases in Neo4j?

大城市里の小女人 提交于 2019-11-27 09:11:57
问题 Is it possible to create/delete different databases in the graph database Neo4j like in MySQL? Or, at least, how to delete all nodes and relationships of an existing graph to get a clean setup for tests, e.g., using shell commands similar to rmrel or rm ? 回答1: You can just remove the entire graph directory with rm -rf , because Neo4j is not storing anything outside that: rm -rf data/* Also, you can of course iterate through all nodes and delete their relationships and the nodes themselves,

Delete all elements of a certain type from an XML doc using PHP

泄露秘密 提交于 2019-11-27 08:15:57
问题 I have what should be an easy task: delete <places> nodes and their descendants from an XML document, leaving other nodes. I tried this code, but it did not work ... $document->preserveWhiteSpace = false; $books = $xpath->query('piletilve_info/places'); //echo "4"; foreach ($books as $places) { while($places->hasChildNodes()) { $places->removeChild($places->childNodes->item(0)); } $places->parentNode->removeChild($places); } Source XML to be processed: <piletilve_info> <places> <place> ... <

Node.js server that accepts POST requests

岁酱吖の 提交于 2019-11-27 06:11:21
I'm trying to allow javascript to communicate with a Node.js server. POST request (web browser) var http = new XMLHttpRequest(); var params = "text=stuff"; http.open("POST", "http://someurl.net:8080", true); http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.setRequestHeader("Content-length", params.length); http.setRequestHeader("Connection", "close"); alert(http.onreadystatechange); http.onreadystatechange = function() { if (http.readyState == 4 && http.status == 200) { alert(http.responseText); } } http.send(params); Right now the Node.js server code looks like

How to compare two DOMs or DOM nodes in general?

旧城冷巷雨未停 提交于 2019-11-27 06:08:11
问题 I am using var win1 = open.window(...); var win2 = open.window(...); to open 2 tabs/windows in Firefox - now I want to compare the two DOMs (document object models) for similarity. So I have got two DOMs containing a very similar page. The pages have the same HTML but executed different JavaScript files. In general I check if HTML and CSS is the same: var html1 = win1.document.body.innerHTML; var html2 = win2.document.body.innerHTML; if (html1 == html2) { ... } var css1 = win1.document.body

Exception in thread “main” java.util.NoSuchElementException: No line found - Using scanner input [duplicate]

谁说胖子不能爱 提交于 2019-11-27 05:29:10
This question already has an answer here: Java Scanner.nextLine() not waiting for input 2 answers java.util.NoSuchElementException: No line found 5 answers I am trying to delete a specific node from a linked list. I am trying to call my method removeNode, but it is giving me this error when I call it to get the user input. Any advice on how to fix this would be greatly appreciated! Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Unknown Source) at LinkedList.removeNode(LinkedList.java:123) at fileIn.<init>(fileIn.java:22) at fileIn.main

Get all child, grandchild etc nodes under parent using php with mysql query results

允我心安 提交于 2019-11-27 05:19:25
I've been trying to figure this out but I haven't gotten anywhere.Hopefully someone can come to my rescue. My problem is I'm using adjacency list data model to produce my hierarchy data in mysql.I can retrieve the table (see below) into a multidimension array with associative array for each item. What I want to do is once I get this array , I want to get another array with all the nodes (child, grandchild etc) under a parent id (including the parent item).I just can't workout how to code tihs in php. In MySQL my table appears like this: id name parent_id 1 Electronics 0 2 Televisions 1 3