Search Results

Search found 602 results on 25 pages for 'getelementsbytagname'.

Page 18/25 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • jquery ajax html response change 1.3.2 vs 1.4.2 (aka where is my script tag?)

    - by cmroanirgo
    I've been using jquery 1.3.2 to pull snippets of html (including script) from a server. A typical response might be: <div id="content"<div id="inner"... <script type=... alert("hello world");</script <pHello World</p </div</div I've been using the query .get function: $.get($(this).attr("href"), function(response) { $("#inner").replaceWith($("#inner", response)); }); And everything is fine and works as expected: the returned html snippets get loaded into the DOM and the scripts run. When I use 1.4.2 however, I notice that the script tags have been removed and no longer run. Stepping into the newer jquery codebase yields the lines of code (line 4498) : ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); which seems to be the culprit 'removing' the script from its happy resting place as part of the selector process. But it doesn't help me in injecting exactly what i want into the DOM. Any idea why jquery is doing this? More importantly, how can I go about fixing this so that my scripts run?

    Read the article

  • sending parameters with ajax

    - by kawtousse
    I am trying to send parameters that I get from a table in my jsp to other JSP using ajax. I am using the followinf function to send all values to JSP: ajaxForm but I don't know why the send failed every time I run it: Here is the javascript function: function editarow() { var xhr = getXhr(); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { selects = xhr.responseText; // On se sert de innerHTML pour rajouter les options a la liste document.getElementById('prjsel').innerHTML = selects; } }; var row, firstNameCell, lastNameCell; var table = document.getElementById("sheet"); var buttons = table.getElementsByTagName("button"); for (var i = 0; i < buttons.length; i++) { if (buttons[i].name == "edit") { buttons[i].onclick = function() { row = this.parentNode.parentNode; // The first name cell is the first child NameCell1 = findElement(row.firstChild); NameCell2 = findElement(NameCell1.nextSibling); NameCell3 = findElement(NameCell2.nextSibling); NameCell4 = findElement(NameCell3.nextSibling); NameCell5 = findElement(NameCell4.nextSibling); NameCell6 = findElement(NameCell5.nextSibling); NameCell7 = findElement(NameCell6.nextSibling); // `innerHTML` pour obtenir la valeur /*alert("name 1 is " + NameCell1.innerHTML); alert("name 2 is " + NameCell2.innerHTML); alert("name 3 is " + NameCell3.innerHTML); alert("name 4 is " + NameCell4.innerHTML); alert("name 5 is " + NameCell5.innerHTML); alert("name 6 is " + NameCell6.innerHTML); alert("name 7 is " + NameCell7.innerHTML);*/ } } } xhr.open("POST", "ajaxForm.jsp", true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send("NameCell1="+NameCell1,"NameCell2="+NameCell2,"NameCell3="+NameCell3,"NameCell4="+NameCell4,"NameCell5="+NameCell5,"NameCell6="+NameCell6,"NameCell7="+NameCell7 ); } After I get the value from the table I want to send all of them to the ajaxForm.jsp.

    Read the article

  • Facebook og:url ignored in favour of a Facebook hosted page about the og entity

    - by Dan
    I am trying to implement the Like button on my pages. Those pages represent the review page for a product. When a user Likes the page, it shows up in Facebook (not as a link, but as liking an entity), however when you click on the entity in Facebook it links through to a facebook.com hosted page representing the page. I want the user to be redirected to the og:url page? This happens for example when you Like an artist page on Grroveshar: http://grooveshark.com/#!/artist/Elbow/4795 I am clearly "doing it wrong". I am using the following markup to include the SDK. MYAPPID is included by the code generator Facebook provides so I assume it is required. <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=MYAPPID"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> Then my code to render the Like button. <div class="fb-like" data-send="false" data-width="450" data-show-faces="true"></div> And finally my og tags: <meta property="og:title" content="My product" /> <meta property="og:type" content="product" /> <meta property="og:url" content="http://site.com/product_1/" /> <meta property="og:image" content="http://site.com/image1.jpg" /> <meta property="og:site_name" content="My-Site-Name.com" /> <meta property="fb:admins" content="MYFACEBOOKID" /> <meta property="fb:app_id" content="MYAPPID" /> Thanks!

    Read the article

  • How to speed up the reading of innerHTML in IE8?

    - by Dennis Cheung
    I am using JQuery with the DataTable plugin, and now I have a big performnce issue on the following line. aLocalData[jInner] = nTds[j].innerHTML; // jquery.dataTables.js:2220 I have a ajax call, and result string in HTML format. I convert them into HTML nodes, and that part is ok. var $result = $('<div/>').html(result).find("*:first"); // simlar to $result=$(result) but much more faster in Fx Then I activate enable the result from a plain table to a sortable datatable. The speed is acceptable in Fx (around 4sec for 900 rows), but unacceptable in IE8 (more then 100 seconds). I check it deep using the buildin profiler, and found the above single line take all 99.9% of the time, how can I speed it up? anything I missed? nTrs = oSettings.nTable.getElementsByTagName('tbody')[0].childNodes; for ( i=0, iLen=nTrs.length ; i<iLen ; i++ ) { if ( nTrs[i].nodeName == "TR" ) { iThisIndex = oSettings.aoData.length; oSettings.aoData.push( { "nTr": nTrs[i], "_iId": oSettings.iNextId++, "_aData": [], "_anHidden": [], "_sRowStripe": '' } ); oSettings.aiDisplayMaster.push( iThisIndex ); aLocalData = oSettings.aoData[iThisIndex]._aData; nTds = nTrs[i].childNodes; jInner = 0; for ( j=0, jLen=nTds.length ; j<jLen ; j++ ) { if ( nTds[j].nodeName == "TD" ) { aLocalData[jInner] = nTds[j].innerHTML; // jquery.dataTables.js:2220 jInner++; } } } }

    Read the article

  • Access is denied

    - by Lasse Gaardsholt
    Hi, I got this code for my sharepoint, but I get a Access is Denied, can anyone help me out here ? <!-- Load and display list - iframe version --> <!-- Questions and comments: [email protected] --> <DIV id="ListPlaceholder"><IMG src="/_layouts/images/GEARS_AN.GIF"></DIV> <!-- Paste the URL of the source list below: --> <iframe id="SourceList" style="display:none;" src="xXxXxX" onload="DisplayThisList()"></iframe> <script type="text/javascript"> function DisplayThisList() { var placeholder = document.getElementById("ListPlaceholder"); var displaylist = null; var sourcelist = document.getElementById("SourceList"); try { if(sourcelist.contentWindow) // Internet Explorer { displaylist = sourcelist.contentWindow.document.getElementById("WebPartWPQ1") ; } } catch(err) { alert(err.message); } displaylist.removeChild(displaylist.getElementsByTagName("table")[0]); placeholder.innerHTML = displaylist.innerHTML; } </script>

    Read the article

  • Ajax Javascript method cannot be called

    - by blackmage
    I made this method to load javascript functions dynamically. It does include the .js file but when I call a method, the method says that it is undefinited. The following to .js files are ajax_object.js and user_manager.js . The alert outside the function is read and works but the alert inside does not. enter code here //ajax_object.js //Load a javascript library function loadJavascript( src, url ){ XMLHttpRequestObject=getXmlHttpRequestObject(); if( XMLHttpRequestObject){ XMLHttpRequestObject.onreadystatechange = function() { if (XMLHttpRequestObject.readyState == 4 ){ if (XMLHttpRequestObject.status == 200 || XMLHttpRequestObject.status == 304) { includeJavaScript( src, url, XMLHttpRequestObject.responseText ); } } } } XMLHttpRequestObject.open('GET', url, true); XMLHttpRequestObject.send(null); }//end LoadJavaScript //Add Library to header function includeJavaScript(src, fileUrl, xmlObject) { if ( ( xmlObject != null ) && ( !document.getElementById( src ) ) ){ var documentHead = document.getElementsByTagName('HEAD').item(0); var includeScript = document.createElement( "script" ); includeScript.language = "javascript"; includeScript.type = "text/javascript"; //includeScript.id = src; includeScript.src=fileUrl.concat(src); includeScript.defer = true; includeScript.text = xmlObject; documentHead.appendChild( includeScript ); } } //user_manager.js //First alert is read alert("Outside User Manager"); function selectUserManagerModuleType(){ XMLHttpRequestObject=getXmlHttpRequestObject(); //This doesn't work //throws selectUserManagerModuleType undefined alert("Inside The User Manager"); }

    Read the article

  • Could my forms be hacked.

    - by Mike Sandman
    Hi there, I posted a question yesterday, which I intend to get back to today however I wrote some JavaScript as a first line of prevention against XSS. However when testing this on my live server I catch some invalid input as the javascript catches the php section. My form uses post and php isn't in my form items (i haven't typed it in). Could this be picking up the form action or something? I'm baffeled, Any ideas Here is my code, it is triggered on the submit button. function validateForBadNess(){ var theShit = new Array("*","^", "$", "(",")","{", "}","[", "]","\", "|", "'","/","?",",","=","","gt","lt", "<","script","`","´","php"); var tagName = new Array(); tagName[0] = "input"; tagName[1] = "select"; tagName[2] = "textbox"; tagName[3] = "textarea"; for (ms=0;ms // loop through the elements of the form var formItems = document.getElementsByTagName(tagName[ms]); for (var xs=0;xs var thisString = formItems[xs].value; // loop through bad array for (zs in theShit){ //alert(thisString + " " + thisString.indexOf(theShit[zs])) if(thisString.indexOf(theShit[zs]) >= 0){ alert("Sorry but the following character: " + theShit[zs] + " is not permitted. Please omit it from your input.\nIf this is part of your password please contact us to heave your password reset.") return false; } } // loop for formitems } // tagName toop } // original condition }

    Read the article

  • A question about DOM parser used with Python

    - by fixxxer
    I'm using the following python code to search for a node in an XML file and changing the value of an attribute of one of it's children.Changes are happening correctly when the node is displayed using toxml().But, when it is written to a file, the attributes rearrange themselves(as seen in the Source and the Final XML below). Could anyone explain how and why this happen? Python code: #!/usr/bin/env python import xml from xml.dom.minidom import parse dom=parse("max.xml") #print "Please enter the store name:" for sku in dom.getElementsByTagName("node"): if sku.getAttribute("name") == "store": sku.childNodes[1].childNodes[5].setAttribute("value","Delhi,India") print sku.toxml() xml.dom.ext.PrettyPrint(dom, open("new.xml", "w")) a part of the Source XML: <node name='store' node_id='515' module='mpx.lib.node.simple_value.SimpleValue' config_builder='' inherant='false' description='Configurable Value'> <match> <property name='1' value='point'/> <property name='2' value='0'/> <property name='val' value='Store# 09204 Staten Island, NY'/> <property name='3' value='str'/> </match> </node> Final XML : <node config_builder="" description="Configurable Value" inherant="false" module="mpx.lib.node.simple_value.SimpleValue" name="store" node_id="515"> <match> <property name="1" value="point"/> <property name="2" value="0"/> <property name="val" value="Delhi,India"/> <property name="3" value="str"/> </match> </node>

    Read the article

  • PHP DOMDocument Error Handling Problem

    - by Jon
    I'm having trouble trying to write an if statement for DOM that will check if $html is blank. However whenever the html page does end up blank, it just removes everything that would be below DOM (including what I had to check if it was blank). $html = file_get_contents("http://example.com/"); $dom = new DOMDocument; @$dom->loadHTML($html); $links = $dom->getElementById('dividhere')->getElementsByTagName('img'); foreach ($links as $link) { echo $link->getAttribute('src'); } All this does is grab an image url in the specified div, which works perfectly until the page is a blank html page. I've tried using SimpleHTMLDOM, which didn't work either (it didn't even fetch the image on working pages). Did I happen to miss something with this one or am I just missing something in both? include_once('simple_html_dom.php') $html = file_get_html("http://example.com/"); foreach($html->find('div[id="dividhere"]') as $div) { if(empty($div->src)) { continue; } echo $div->src; }

    Read the article

  • 'NoneType' object has no attribute 'data'

    - by Bill Jordan
    Hello guys, I am sending a SOAP request to my server and getting the response back. sample of the response string is shown below: <?xml version = '1.0' ?> <env:Envelope xmlns:env=http:////www.w3.org/2003/05/soap-envelop . .. .. <env:Body> <epas:get-all-config-resp xmlns:epas="urn:organization:epas:soap"> ^M ... ... <epas:property name="Tom">12</epas:property> > > <epas:property name="Alice">34</epas:property> > > <epas:property name="John">56</epas:property> > > <epas:property name="Danial">78</epas:property> > > <epas:property name="George">90</epas:property> > > <epas:property name="Luise">11</epas:property> ... ^M </env:Body? </env:Envelop> What I noticed in the response is that there is an extra character shown in the body which is "^M". Not sure if this could be the issue. Note the ^M shown! when I tried parsing the string returned from the server to get the names and values using the code sample: elements = minidom.parseString(xmldoc).getElementsByTagName("property") myDict = {} for element in elements: myDict[element.getAttribute('name')] = element.firstChild.data But, I am getting this error: 'NoneType' object has no attribute 'data'. May be its something to do with the "^M" shown on the xml response back! Any ideas/comments would be appreciated, Cheers

    Read the article

  • How-to display a .gif as background image?

    - by Vito De Tullio
    Hi! I have a javascript "loading" function like this: function splashScreen() { var div = document.createElement('div'); div.appendChild(document.createTextNode("some text")); div.setAttribute("style", "position: fixed; " + "width: 100%; height: 100%; " + "left: 0; top: 0; " + "z-index: 1000; " + "background: #fff url('img/loading.gif') no-repeat center; " + "font-size: x-large; " + "text-align: center; " + "line-height: 3em; " + "opacity: 0.75; " + "filter: alpha(opacity=75); "); document.getElementsByTagName('body')[0].appendChild(div); return true; } I use this function in the form action (onsubmit="return splashScreen()") to show a "rotating logo" while the next page load... The problem is in that "img/loading.gif" and safari (on winXP): in ff and ie I have no problems, and I clearly see the animated gif. In safari I can't see it. If I change the image with a (obviously static) png the image appears... Am I doing something wrong? What's the problem with safari?

    Read the article

  • javascript equivalent of ASP preInit event

    - by Pankaj Kumar
    Hi guys, searching for this has yielded no resuts.. i have a middle page that has an iframe and all the pages open in that iframe...i have to implement a chat system just like in Google and so to ensure that the chat windows did not close whwn the page would postback i am opening all pages in iframe.... this is a social networking site and user can have themes which have background images per theme now when i visit a friends profile the backgrounf image of the middle page should change... i have this code to find parent of iframe and change background image $(document).ready(function(){ var theme=document.getElementById("ctl00_decideFooterH").value; var t= parent.document.getElementsByTagName("body"); if(theme=='basicTheme'){ t[0].className="basic"; } else if(theme=='Tranquility') { t[0].className="Tranquility"; } else if(theme=='AbstractPink') { t[0].className="abstractPink"; } }); and this code is the master page that all child pages that would open in iframe would access..the trouble is that there is a lag between the theme application on server side(which happens at PreInit) and the background image change which is done by this document.ready that gets executed after the iframe has loaded.. so essentially i need a javascript function that would either execute parallel to PreInit or some other logic....so guys plz help its urgent

    Read the article

  • XML parsing by DOM

    - by blackpearl
    NodeList nList2 = doc.getElementsByTagName("dep"); Map<String, List<Map<String, String>>> depMap = new HashMap<String, List<Map<String, String>>>(); for (int temp = 0; temp < nList2.getLength(); temp++) { Element el = (Element)nList2.item(temp); String type=el.getAttribute("type"); Node nNode = nList2.item(temp); if (nNode.getNodeType() == Node.ELEMENT_NODE) { Element eElement = (Element) nNode; List<Map<String,String>> depList = new ArrayList<Map<String,String>>(); String governor = getTagValue("governor", eElement); String dependent = getTagValue("dependent", eElement); Map<String, String> govdepmap = new HashMap<String, String>(); govdepmap.put(governor, dependent); depList.add(govdepmap); List<Map<String,String>> flist = new ArrayList<Map<String,String>>(); flist.add(govdepmap); depMap.put(type, flist); } } I have the following structure in my XML file: going I Now i want to store the "idx" attribute of each "governor" and "dependent" tag. What code should I change or add?

    Read the article

  • Iterating Over <select> Using jQuery + Multi Select

    - by Kezzer
    This isn't quite as straight forward as one may think. I'm using a plugin called jQuery MultiSelect and multiple <select options using XSLT as follows: <xsl:for-each select="RootField"> <select id="{RootField}" multiple="multiple" size="3"> <option value=""></option> <xsl:for-each select="ChildField"> <option value="{ChildField}"><xsl:value-of select="ChildField"/></option> </xsl:for-each> </select> </xsl:for-each> The accompanying JavaScript is as follows: var selects = document.getElementsByTagName("select"); $.each(selects, function() { $(this).multiSelect(); }); This allows me to apply the multiSelect(); function to every single <select on the page. The behaviour is quite strange, every other <select is being changed into the dropdown list (all the even ones anyway). I can't see anything wrong in my JavaScript to cause this issue as it would iterate over every single one. To make it more clear, the only lists that have that JavaScript applied to it are ones in position 2, 4, 6 and 8 (out of the 9 which are on the page). Any ideas?

    Read the article

  • Google AJAX Transliteration API :- How do i translate many elements in page to some language at one

    - by Nitesh Panchal
    Hello, I have many elements on page and all of which i want to translate to some language. The language is not the same for all fields, that is, for 1st field it may be fr and for third field it may be en then again for 7th field it may be pa. Basically i wrote the code and it's working :- <script type="text/javascript"> //<![CDATA[ google.load("language", "1"); window.onload = function(){ var elemPostTitles = document.getElementsByTagName("h4"); var flag = true; for(var i = 0 ; i < elemPostTitles.length ; i++){ while(flag == false){ } var postTitleElem = elemPostTitles[i]; var postContentElem = document.getElementById("postContent_" + i); var postTitle = postTitleElem.innerHTML; var postContent = postContentElem.innerHTML; var languageCode = document.getElementById("languageCode_" + i).value; google.language.detect(postTitle, function(result) { if (!result.error && result.language) { google.language.translate(postTitle, result.language, languageCode, function(result) { flag = true; if (result.translation) { postTitleElem.innerHTML = result.translation; } }); } }); flag = false; } As you can see, what i am trying to do is restrict the loop from traversing until the result of previous ajax call is receieved. If i don't do this only the last field gets translated. My code works nicely, but because of the infinite loop, i keep getting errors from Mozilla to "stop executing scripts". How do i get rid of this? Also, is my approach correct? Or some inbuilt function is available which can ease my task? Thanks in advance :)

    Read the article

  • Checking whether images loaded after page load

    - by johkar
    Determining whether an image has loaded reliably seems to be one of the great JavaScript mysteries. I have tried various scripts/script libraries which check the onload and onerror events but I have had mixed and unreliable results. Can I reliably just check the complete property (IE 6-8 and Firefox) as I have done in the script below? I simply have a page wich lists out servers and I link to an on.gif on each server. If it doesn't load I just want to load an off.gif instead. This is just for internal use...I just need it to be reliable in showing the status!!! <script type="text/javascript"> var allimgs = document.getElementsByTagName('img'); function checkImages(){ for (i = 0; i < allimgs.length; i++){ var result = Math.random(); allimgs[i].src = allimgs[i].src + '?' + result; } serverDown(); setInterval('serverDown()',5000); } window.onload=checkImages; function serverDown(){ for (i = 0; i < allimgs.length; i++){ var imgholder=new Image(); imgholder.src=allimgs[i].src; if(!allimgs[i].complete){ allimgs[i].src='off.gif'; } } } </script>

    Read the article

  • Read IFrame content using JavaScript

    - by Rajat
    Ok, This is my first time dealing seriously with IFrames and I cant seem to understand a few things: First the sample code I am testing with: <head> <script type="text/javascript"> function init(){ console.log("IFrame content: " + window.frames['i1'].document.getElementsByTagName('body')[0].innerHTML); } </script> </head> <body onload="init();"> <iframe name="i1" src="foo.txt"/> </body> the file "foo.txt" looks like this: sample text file Questions: 1) The iframe seems to be behaving as a HTML document and the file text is actually part of the body instead. Why ? Is it a rule for an IFrame to be a HTML document. Is it not possible for the content of an iframe to be just plain text ?? 2) The file content gets wrapped inside a pre tag for some reason. Why is this so ? Is it always the case? 3) My access method in the javascript is working but is there any other alternative? [native js solutions please] If the content is wrapped in a pre tag always then I will actually have to lookup inside the pre tag rather than lookup the innerHTML

    Read the article

  • Using AJAX to get a specific DOM Element (using Javascript, not jQuery)

    - by Matt Frost
    How do you use AJAX (in plain JavaScript, NOT jQuery) to get a page (same domain) and display just a specific DOM Element? (Such as the DOM element marked with the id of "bodyContent"). I'm working with MediaWiki 1.18, so my methods have to be a little less conventional (I know that a version of jQuery can be enabled for MediaWiki, but I don't have access to do that so I need to look at other options). I apologize if the code is messy, but there's a reason I need to build it this way. I'm mostly interested in seeing what can be done with the Javascript. Here's the HTML code: <div class="mediaWiki-AJAX"><a href="http://www.domain.com/whatever"></a></div> Here's the Javascript I have so far: var AJAXs = document.getElementsByClassName('mediaWiki-AJAX'); if (AJAXs.length > 0) { for (var i = AJAXs.length - 1; i >= 0; i--) { var URL = AJAXs[i].getElementsByTagName('a')[0].href; xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { AJAXs[i].innerHTML = xmlhttp.responseText; } } xmlhttp.open('GET',URL,true); xmlhttp.send(); } }

    Read the article

  • 'send' button error 401

    - by jjd
    I'm having a strange error with 'Send' button I have the following code on my page <div id="fb-root"></div> <script type="text/javascript"> (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&amp;appId=<myAppId>"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <br/> <fb:like send="true" width="450" show_faces="true"></fb:like> The 'send' button works fine if I access the application via IP address, but if I use a domain name, Facebook returns The page at http://<...>.com:8080/pages/question.jsf could not be reached because the server returned status code 401. Meantime 'like' button works fine. The application front-end is built with JSF2+Primefaces. Any ideas would be appreciated Thanks

    Read the article

  • How someone using my Facebook website app can post to their pages timeline

    - by user1334414
    I have a website where businesses create content through a PHP backend system. Each time they create a new piece of content, I want it to publish to their Facebook pages timeline (not the users timeline). I have created the authenticate code: <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId : 'XXXXXXXXXX', status : true, cookie : true, xfbml : true, oauth : true, }); }; (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; d.getElementsByTagName('head')[0].appendChild(js); }(document)); </script> <div class="fb-login-button" scope="manage_pages"> Login with Facebook </div> With manage_pages as a scope. I need to know how they can select which page they want the post to go to (if they have more than 1 page), and also how to automatically post to that pages wall when they submit the content (which is done via a PHP form). Thanks

    Read the article

  • Java: Ignoring escapes when parsing XML

    - by Personman
    I'm using a DocumentBuilder to parse XML files. However, the specification for the project requires that within text nodes, strings like " and < be returned literally, and not turned into the corresponding ASCII values. A previous similar question, http://stackoverflow.com/questions/1979785/read-escaped-quote-as-escaped-quote-from-xml, received one answer that seems to be specific to Apache, and another that appears to simply not not do what it says it does. I'd love to be proven wrong on either count, however :) For reference, here is some code: file = new File(fileName); DocBderFac = DocumentBuilderFactory.newInstance(); DocBder = DocBderFac.newDocumentBuilder(); doc = DocBder.parse(file); NodeList textElmntLst = doc.getElementsByTagName(text); Element textElmnt = (Element) textElmntLst.item(0); NodeList txts = textElmnt.getChildNodes(); String txt = ((Node) txts.item(0)).getNodeValue(); System.out.println(txt); I would like that println() to produce things like &quot;3&gt;2&quot; instead of "3>2" which is what currently happens. Thanks!

    Read the article

  • UnicodeEncodeError: 'ascii' codec can't encode character [...]

    - by user1461135
    I have read the HOWTO on Unicode from the official docs and a full, very detailed article as well. Still I don't get it why it throws me this error. Here is what I attempt: I open an XML file that contains chars out of ASCII range (but inside allowed XML range). I do that with cfg = codecs.open(filename, encoding='utf-8, mode='r') which runs fine. Looking at the string with repr() also shows me a unicode string. Now I go ahead and read that with parseString(cfg.read().encode('utf-8'). Of course, my XML file starts with this: <?xml version="1.0" encoding="utf-8"?>. Although I suppose it is not relevant, I also defined utf-8 for my python script, but since I am not writing unicode characters directly in it, this should not apply here. Same for the following line: from __future__ import unicode_literals which also is right at the beginning. Next thing I pass the generated Object to my own class where I read tags into variables like this: xmldata.getElementsByTagName(tagName)[0].firstChild.data and assign it to a variable in my class. Now what perfectly works are those commands (obj is an instance of the class): for element in obj: print element And this command does work as well: print obj.__repr__() I defined __iter__() to just yield every variable while __repr__() uses the typical printf stuff: "%s" % self.varname Both commands print perfectly and can output the unicode character. What does not work is this: print obj And now I am stuck because this throws the dreaded UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 47: So what am I missing? What am I doing wrong? I am looking for a general solution, I always want to handle strings as unicode, just to avoid any possible errors and write a compatible program. Edit: I also defined this: def __str__(self): return self.__repr__() def __unicode__(self): return self.__repr__() From documentation I got that this

    Read the article

  • jQuery and Ajax

    - by Banderdash
    Can anyone help with a jQuery snippet that would use Ajax to pull an XML file in on page load? Have really clunky way of doing it without jQuery here: <script type="text/javascript"> function loadXMLDoc() { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { xmlDoc=xmlhttp.responseXML; var txt=""; x=xmlDoc.getElementsByTagName("title"); for (i=0;i<x.length;i++) { txt=txt + x[i].childNodes[0].nodeValue + "<br />"; } document.getElementById("checkedIn").innerHTML=txt; } } xmlhttp.open("GET","ajax-response-data.xml",true); xmlhttp.send(); } </script> Ideally rather the having a click generate the list it would do so on page load, showing the fields from the XML (title, author, and whether it is checked in or not i.e. <book id="#" checked-in="0">) Would hug you for a solution.

    Read the article

  • Asp.Net Basic Program

    - by Abid Ali
    I want to Visible the combo Box named Cities when i click the Country Pakistan.. but the combo box visibility remains Hidden.. how do i do so ? I think my Code is correct but it is not working :s .. Help Required.. <select id="Items" name = "Countries"> <option id="Pakistan" onclick="VisibileTrue()">Pakistan</option> <option id = "Taiwan">Taiwan</option> </select> <select id="Items2" name="Cities" style="display:none" > <option>Karachi</option> <option>Sindh</option> </select> </div> </form> function VisibileTrue() { var element = document.getElementById(Pakistan); if(element == Pakistan) { var element2 = document.getElementsByTagName("Items2"); element2.style.display = "inline"; } }

    Read the article

  • On Render Callback For G+ Button

    - by Michael Robinson
    How might I go about performing an action only when a G+ button has finished rendering? Facebook allows one to do this using the following: FB.XFBML.parse(document, function() { alert('rendering done'); }); I've perused Google's documentation, but didn't see anything helpful. Currently my workaround is to monitor the G+ element until certain elements have been added, then perform my action: (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; po.onload = function() { var awaitRender = function(element) { if (element.firstChild && element.firstChild.firstChild && element.firstChild.firstChild.tagName.toUpperCase() === 'IFRAME') { alert('rendered!'); } else { window.setTimeout(function() { awaitRender(element) }, 100); } }; var buttons = document.getElementsByClassName('googleplus-button'); for(var i = 0; i < buttons.length; i++) { awaitRender(buttons[i]); } } var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); I'd like to know please, if there is either: A correct way one should do this for G+ buttons A better implementation that what I've hacked together above

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >