Search Results

Search found 3639 results on 146 pages for 'dom manipulation'.

Page 7/146 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • JQuery traverse DOM and extract node value

    - by Alex
    I have the following DOM: <div class="qtip qtip-light qtip-active"> <div class="qtip-wrapper"> <div class="qtip-borderTop"></div> <div class="qtip-contentWrapper"> <div class="qtip-title"> <div class="qtip-button"></div> **Text I need to extract** </div> <div class="qtip-content"> <div class="tooltip"> <div class="button-container"> <script type="text/javascript"> var link = null; var link = $('.qtip-active > .qtip-title').val(); $('.qtip-active > #button-container').append('<a href=\"mailto:' + link + '\">' + link + '</a>'); </script> </div> </div> </div> </div> <div class="qtip-borderBottom"></div> </div> </div> But the variable link is always undefined when I would expect it to return the text the node specified. I've been reading the jquery documentation for a few hours but I must be missing something with my logic (or lack there of). Any help appreciated...

    Read the article

  • PHP Simple DOM Parser

    - by Junior Coder
    Hi guys I'm using this wonderful class here to do a bit of code embed filtering: http://simplehtmldom.sourceforge.net/. It extends the PHP DOM document class. Pretty much what I am doing is parsing a string through this class that contains embed code, i grab the unique bits of information eg id, width, height send through a handler function which inserts the id, width, height etc into my predefined "safe" template and reinsert my safe template in the place of the embed code the user has put in. May seem a backward way of doing it but it's the way it has to be done :) All of that works fine. Problem is when there is more than just embed code contained in the string, as I can't just replace the embed code i can only replace the entire string which wipes the rest of the tags etc string. For example if there were a p tag that would be wiped. So my question is how using this class can i just replace the certain part of the string? Spent the last few days trying to work this out and need some more input. It appears the class can do this so i'm stumped. Here's a basic version of what i have so far :) // load the class $html = new simple_html_dom(); // load the entire string containing everything user entered here $return = $html->load($string); // check for embed tags if($html->find('embed') == true { foreach($html->find('embed') as $element) { // send it off to the function which returns a new safe embed code $element = create_new_embed($parameters); // this is where i somehow i need to save the changes and send it back to $return } } Any input would be gratefully appreciated. If i have explained my problem well enough please let me know :)

    Read the article

  • YUI: ensuring DOM elements and scripts are ready

    - by dound
    If I put my inline script after the DOM elements it interacts with, should I still use YUI 3's domready event? I haven't noticed any problems, and it seems like I can count on the browser loading the page sequentially. (I already use YUI().use('node', ... to make sure the YUI functions I need have been loaded since the YUI script is a separate file.) Is there a way to speed up the loading of widgets like YUI 2's calendar? I load the appropriate script in <head> element of my page. I use YUI().use('yui2-calendar', ... to make sure the Calendar widget is available. Unfortunately, this causes a short but noticeable delay when I load my page with the calendar. If I omit the YUI().use('yui2-calendar', ... code then it shows up without a noticeable delay - but I guess this could cause the Calendar to not show up at all if the YUI script doesn't load in time? With regards to #2, is it possible to reduce the visual artifact of the calendar not being present and then showing up? I've made it slightly better by specifying a height and width for the parent div so that at least the space is already allocated = minimal shifting around when it does load.

    Read the article

  • Help Modifying Generic REST Helper PHP Example Code to Support XML DOM

    - by Jennifer Baker
    Hi! I found this example PHP source code at HTTP POST from PHP, without cURL I need some help modifying the example PHP source to support XML DOM for manipulating a REST API. I thought that if I update the CASE statement for the XML section below from $r = simplexml_load_string($res); to $r = new DOMDocument(); $r->load($res); that it would work but it doesn't. :( Any help would be appreciated. function rest_helper($url, $params = null, $verb = 'GET', $format = 'xml') { $cparams = array( 'http' => array( 'method' => $verb, 'ignore_errors' => true ) ); if ($params !== null) { $params = http_build_query($params); if ($verb == 'POST') { $cparams['http']['content'] = $params; } else { $url .= '?' . $params; } } $context = stream_context_create($cparams); $fp = fopen($url, 'rb', false, $context); if (!$fp) { $res = false; } else { // If you're trying to troubleshoot problems, try uncommenting the // next two lines; it will show you the HTTP response headers across // all the redirects: // $meta = stream_get_meta_data($fp); // var_dump($meta['wrapper_data']); $res = stream_get_contents($fp); } if ($res === false) { throw new Exception("$verb $url failed: $php_errormsg"); } switch ($format) { case 'json': $r = json_decode($res); if ($r === null) { throw new Exception("failed to decode $res as json"); } return $r; case 'xml': $r = simplexml_load_string($res); if ($r === null) { throw new Exception("failed to decode $res as xml"); } return $r; } return $res; }

    Read the article

  • Using JQuery to traverse DOM structure, finding a specific <table> element located after HTML 'comme

    - by Shadow
    I currently have a website source code (no control over the source) which contains certain content that needs to be manipulated. This would be simple on the surface, however there is no unique ID attribute on the tag in question that can uniquely identify it, and therefore allow for further traversal. Here is a snippet of the source code, surrounding the tag in question. ... <td width="100%"> <!--This table snaps the content columns(one or two)--> <table border="0" width="100%"> ... Essentially, the HTML comment stuck out as an easy way to gain access to that element. Using the JQuery comment add-on from this question, and some help from snowlord comment below, I have been able to identify the comment and retrieve the following output using the 'dump' extension. $('td').comments().filter(":contains('This table snaps the content columns(one or two)')").dump(); returns; jQuery Object { 0 = DOMElement [ nodeName: DIV nodeValue: null innerHTML: [ 0 = String: This table snaps the content columns(one or two) ] ] } However I am not sure how to traverse to the sibling element in the DOM. This should be simple, but I haven't had much selector experience with JQuery. Any suggestions are appreciated.

    Read the article

  • Replacing tags inside the parent tag using DOM PHP

    - by user585303
    Here is what I got: <div id="list"> <ol> <li>Ordered list 1</li> <li>Ordered list 2</li> <ul><li>Unordered list inside ol ul</li></ul> <ol><li>Ordered list inside ol ol</li></ol> <ol> <ul> <li>Unordered list</li> <ol><li>Ordered list inside ul</li></ol> <ul> <ol> <li>Ordered list 1</li> <ol><li>Ordered list inside ol ol</li></ol> <ol> </div> I need somehow replace LI tags only inside div id="list" - OL tags I need so that it replaces only LI tags only within the first OL tags and not UL or the once inside OL - OL tags I tried using preg_replace_callback but it only replaces all LI tags inside id="list" and from what i figured it will be over my head to limit replacement only with first ol tags and not the rest, so I been suggested to try out PHP DOM since it should be as easy as div id="list" - OL I would appreciate if someone got me started with the code, maybe with something as replacing all LI tags with in the first OL tag within the whole content.

    Read the article

  • How do I extract this value using PHP Dom

    - by mathew
    Hello I do have html file this is just a prt of it though... <div id="result" > <div class="res_item" id="1" h="63c2c439b62a096eb3387f88465d36d0"> <div class="res_main"> <h2 class="res_main_top"> <img src="/ff/gigablast.com.png" alt="favicon for gigablast.com" width=16 height=16 />&nbsp; <a href="http://www.gigablast.com/" rel="nofollow" > Gigablast </a> <div class="res_main"> <h2 class="res_main_top"> <img src="/ff/ask.com.png" alt="favicon for ask.com" width=16 height=16 />&nbsp; <a href="http://ask.com/" rel="nofollow" > Ask.com - What&#039;s Your Question? </a>.... I want extract only url address (for example: http://www.gigablast.com and http://ask.com/ - there are atleast 10 urls in that html) from above using PHP Dom Document..I know up to this but dont know how to move ahead?? $doc = new DomDocument; $doc->loadHTMLFile('urllist.html'); $data = $doc->getElementById('result'); then what?? this is inside tag hence I cant use $data->getElementsByTagName() here!! any help??

    Read the article

  • Modifying DOM of a webpage

    - by Prashant Singh
    The structure of a webpage is like this :- <div id='abc'> <div class='a'>Some contents here </div> <div class='b'>Some other contents< </div> </div> My aim is to add this after the class a in above structure. <div class='a'>Some other contents here </div> So that final structure looks like this :- <div id='abc'> <div class='a'>Some contents here </div> <div class='a'>Some other contents here </div> <div class='b'>Some other contents< </div> </div> Can there be a better way to do this using DOM properties. I was thinking of naive way of parsing the content and updating. Please comment if I am unclear in asking my doubt !

    Read the article

  • Adding new elements into DOM using JavaScript (appendChild)

    - by KatieK
    I sometimes need to add elements (such as a new link and image) to an existing HTML page, but I only have access to a small portion of the page far from where I need to insert elements. I want to use DOM based JavaScript techniques, and I must avoid using document.write(). Thus far, I've been using something like this: // Create new image element var newImg = document.createElement("img"); newImg.src = "images/button.jpg"; newImg.height = "50"; newImg.width = "150"; newImg.alt = "Click Me"; // Create new link element var newLink = document.createElement("a"); newLink.href = "/dir/signup.html"; // Append new image into new link newLink.appendChild(newImg); // Append new link (with image) into its destination on the page document.getElementById("newLinkDestination").appendChild(newLink); Is there a more efficient way that I could use to accomplish the same thing? It all seems necessary, but I'd like to know if there's a better way I could be doing this. Thanks!

    Read the article

  • jquery displaying table rows dynamically in dom belonging to one/more particular class

    - by whatf
    I have the basic html structure: <table> <tbody> <tr class="1"> <td> <p style="font-size:large"> <span class="muted"> This is the first object </span> </p> </td> </tr> <tr class="2"> <td> <p style="font-size:large"> <span class="muted"> This is second object </span> </p> </td> </tr> <tr class="3"> <p style="font-size:large"> <span class="muted"> this is the third object </span> </p> </td> </tr> </tbody> </table> and then I have check boxes, the functionality i want is, if checkbox 1 is checked, only the tr with class 1 be displayed. if checkbox 2 and 3 are clicked, the tr with class 1 gets hidden and 2, 3 show in the dom. again if checkbox 2,*3* are unchecked and 1 is checked tr with class 2, 3 do not show and 1 is showed. How can this be done in jQuery?

    Read the article

  • Colorbox class don't work with ajax/dom object

    - by almal
    i usually use colorbox tool for open "popup windows" in my page and all are fine. In my new project the situation is little different because i use js/ajax/dom for create dinamically my objects in handleRequestStateChange() function. After import js,jquery and css for colorbox, in the head of my js page i write: $(document).ready(function () { $(window).scroll(function () { //oP1 = document.createTextNode(posizione_menu.offsetTop); //divIpt.appendChild(oMtx1); $(".divHcss").css("position", "fixed").css("top", "0px").css("z-index", "999"); }); //Examples of how to assign the Colorbox event to elements $(".group1").colorbox({rel:'group1'}); $(".group2").colorbox({rel:'group2', transition:"fade"}); $(".group3").colorbox({rel:'group3', transition:"none", width:"75%", height:"75%"}); $(".group4").colorbox({rel:'group4', slideshow:true}); $(".ajax").colorbox(); $(".youtube").colorbox({iframe:true, innerWidth:640, innerHeight:390}); $(".vimeo").colorbox({iframe:true, innerWidth:500, innerHeight:409}); $(".iframe").colorbox({iframe:true, width:"80%", height:"80%"}); $(".inline").colorbox({inline:true, width:"50%"}); $(".callbacks").colorbox({ onOpen:function(){ alert('onOpen: colorbox is about to open'); }, onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); }, onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); }, onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); }, onClosed:function(){ alert('onClosed: colorbox has completely closed'); } }); $('.non-retina').colorbox({rel:'group5', transition:'none'}) $('.retina').colorbox({rel:'group5', transition:'none', retinaImage:true, retinaUrl:true}); //Example of preserving a JavaScript event for inline calls. $("#click").click(function(){ $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here."); return false; }); }); and after in handleRequestStateChange() i create my a element and assign to a div: var a = createElement('a'); //a.style.display = "block"; a.setAttribute('class','iframe'); a.setAttribute('href',"php/whois.php?P1="+oStxt.value); var divIp3 = createElement('div', 'divIp3', 'divIp3css'); var divIp31 = createElement('div', 'divIp31', 'divIp31css'); divIp3.appendChild(divIp31); divIp3.appendChild(a); a.appendChild(divIp31); The divIp31 become linkable but the href open page in a normal browser tab and not using attribute class for colorbox. Someone have an idea about? Thanks in advance AM

    Read the article

  • DOM memory issue with IE8 (inserting lots of JSON data)

    - by okie.floyd
    i am developing a small web-utility that displays some data from some database tables. i have the utility running fine on FF, Safari, Chrome..., but the memory management on IE8 is horrendous. the largest JSON request I do will return information to create around 5,000 or so rows in a table within the browser (3 columns in the table). i'm using jquery to get the data (via getJSON). to remove the old/existing table, i'm just doing a $('#my_table_tbody').empty(). to add the new info to the table, within the getJSON callback, i am just appending each table row that i am creating to a variable, and then once i have them all, i am using $('#my_table_tbody').append(myVar) to add it to the existing tbody. i don't add the table rows as they are created because that seems to be a lot slower than just adding them all at once. does anyone have any recommendation on what someone should do who is trying to add thousands of rows of data to the DOM? i would like to stay away from pagination, but i'm wondering if i don't have a choice. Update 1 So here is the code I was trying after the innerHTML suggestion: /* Assuming a div called 'main_area' holds the table */ document.getElementById('main_area').innerHTML = ''; $.getJSON("my_server", {my: JSON, args: are, in: here}, function(j) { var mylength = j.length; var k =0; var tmpText = ''; tmpText += /* Add the table, thead stuff, and tbody tags here */; for (k = mylength - 1; k = 0; k--) { /* stack overflow wont let me type greater than & less than signs here, so just assume that they are there. */ tmpText += 'tr class="' + j[k].row_class . '" td class="col1_class" ' + j[k].col1 + ' /td td class="col2_class" ' + j[k].col2 + ' /td td class="col3_class" ' + j[k].col3 + ' /td /tr'; } document.getElementById('main_area').innerHTML = tmpText; } That is the gist of it. I've also tried using just a $.get request, and having the server send the formatted HTML, and just setting that in the innerHTML (i.e. document.getElementById('main_area').innerHTML = j;). thanks for all of the replies. i'm floored with the fact that you all are willing to help.

    Read the article

  • PHP: Displaying Dom object and Creating xml file

    - by pavun_cool
    <?php $books = array(); $books [] = array( 'title' => 'PHP Hacks', 'author' => 'Jack Herrington', 'publisher' => "O'Reilly" ); $books [] = array( 'title' => 'Podcasting Hacks', 'author' => 'Jack Herrington', 'publisher' => "O'Reilly" ); $doc = new DOMDocument(); $doc->formatOutput = true; $r = $doc->createElement( "books" ); $doc->appendChild( $r ); foreach( $books as $book ) { $b = $doc->createElement( "book" ); $author = $doc->createElement( "author" ); $author->appendChild( $doc->createTextNode( $book['author'] ) ); #$author->appendChild( $doc->createTextNode( 'pavunkumar')); $new = $doc->createElement("Developer"); $a=$doc->createTextNode('I am developer ' ); $new->appendChild($a); $b->appendChild( $author ); $b->appendChild($new); $b->appendChild($new); $title = $doc->createElement( "title" ); $title->appendChild( $doc->createTextNode( $book['title'] ) ); $b->appendChild( $title ); $publisher = $doc->createElement( "publisher" ); $publisher->appendChild( $doc->createTextNode( $book['publisher'] ) ); $b->appendChild( $publisher ); $r->appendChild( $b ); } echo $doc->SaveXml() ; ?> When I run this code in command line. I am getting following things <?xml version="1.0"?> <books> <book> <author>Jack Herrington</author> <Developer>I am developer </Developer> <title>PHP Hacks</title> <publisher>O'Reilly</publisher> </book> <book> <author>Jack Herrington</author> <Developer>I am developer </Developer> <title>Podcasting Hacks</title> <publisher>O'Reilly</publisher> </book> </books> When I run the code in web browser it gives me following things Jack Herrington I am developer O'Reilly Jack Herrington I am developer O'Reilly I want to above output to be like command line output. And one more things is that instead of displaying , how could I create a xml file using $doc Dom object.

    Read the article

  • Need help accessing PHP DOM elements

    - by Michael Pasqualone
    Hey guys, I have the following HTML structure that I am trying to pull information from: // Product 1 <div class="productName"> <span id="product-name-1">Product Name 1</span> </div> <div class="productDetail"> <span class="warehouse">Warehouse 1, ACT</span> <span class="quantityInStock">25</span> </div> // Product 2 <div class="productName"> <span id="product-name-2">Product Name 2</span> </div> <div class="productDetail"> <span class="warehouse">Warehouse 2, ACT</span> <span class="quantityInStock">25</span> </div> … // Product X <div class="productName"> <span id="product-name-X">Product Name X</span> </div> <div class="productDetail"> <span class="warehouse">Warehouse X, ACT</span> <span class="quantityInStock">25</span> </div> I don't have control of the source html and as you'll see productName and it's accompanying productDetail are not contained within a common element. Now, I am using the following php code to try and parse the page. $html = new DOMDocument(); $html->loadHtmlFile('product_test.html'); $xPath = new DOMXPath($html); $domQuery = '//div[@class="productName"]|//div[@class="productDetail"]'; $entries = $xPath->query($domQuery); foreach ($entries as $entry) { echo "Detail: " . $entry->nodeValue) . "<br />\n"; } Which prints the following: Detail: Product Name 1 Detail: Warehouse 1, ACT Detail: 25 Detail: Product Name 2 Detail: Warehouse 2, ACT Detail: 25 Detail: Product Name X Detail: Warehouse X, ACT Detail: 25 Now, this is close to what I want. But I need to do some processing on each Product, Warehouse and Quantity stock and can't figure out how to parse it out into separate product groups. The final output I am after is something like: Product 1: Name: Product Name 1 Warehouse: Warehouse 1, ACT Stock: 25 Product 2: Name: Product Name 2 Warehouse: Warehouse 2, ACT Stock: 25 I can't just figure it out, and I can't wrap my head around this DOM stuff as the elements don't quite work the same as a standard array. If anyone can assist, or point me in the right direction I will be ever appreciative.

    Read the article

  • javascript DOM how to know what node is?

    - by Fernando SBS
    here is the source code: <table id="movements" cellpadding="1" cellspacing="1"><thead><tr><th colspan="3">Movimentações de tropas:</th></tr></thead><tbody><tr> <td class="typ"><a href="build.php?gid=16"><img src="img/x.gif" class="att1" alt="Tropas atacantes chegando" title="Tropas atacantes chegando" /></a><span class="a1">&raquo;</span></td> <td><div class="mov"><span class="a1">1&nbsp;Ataque</span></div><div class="dur_r">em&nbsp;<span id="timer1">13:21:06</span>&nbsp;hrs.</div></div></td></tr><tr> <td class="typ"><a href="build.php?gid=16"><img src="img/x.gif" class="def1" alt="Tropas de reforço chegando" title="Tropas de reforço chegando" /></a><span class="d1">&raquo;</span></td> <td><div class="mov"><span class="d1">1&nbsp;Reforço</span></div><div class="dur_r">em&nbsp;<span id="timer2">0:14:55</span>&nbsp;hrs.</div></div></td></tr><tr> <td class="typ"><a href="build.php?gid=16"><img src="img/x.gif" class="att2" alt="Próprias tropas atacando" title="Próprias tropas atacando" /></a><span class="a2">&laquo;</span></td> <td><div class="mov"><span class="a2">1&nbsp;Ataque</span></div><div class="dur_r">em&nbsp;<span id="timer3">0:08:50</span>&nbsp;hrs.</div></div></td></tr><tr> <td class="typ"><a href="build.php?gid=16"><img src="img/x.gif" class="def2" alt="Próprias tropas reforçando" title="Próprias tropas reforçando" /></a><span class="d2">&laquo;</span></td> <td><div class="mov"><span class="d2">1&nbsp;Reforço</span></div><div class="dur_r">em&nbsp;<span id="timer4">2:50:45</span>&nbsp;hrs.</div></div></td></tr></tbody></table> and this is the View Source Chart of the document html (for easy DOM working): I would like to get to the 0:14:55 value coming from <span class="d1">, how to do it? EDIT Marcel Korpel: The value is always in the span in a div coming directly after a div containing a span with class d1, like: <div class="mov"><span class="d1">1&nbsp;Reforço</span></div><div class="dur_r">em&nbsp;<span id="timer2">0:14:55</span>&nbsp;hrs.</div>

    Read the article

  • JavaScript and XML Dom - Nested Loop

    - by BSteck
    So I'm a beginner in XML DOM and JavaScript but I've run into an issue. I'm using the script to display my XML data in a table on an existing site. The problem comes in nesting a loop in my JavaScript code. Here is my XML: <?xml version="1.0" encoding="utf-8"?> <book_list> <author> <first_name>Mary</first_name> <last_name>Abbott Hess</last_name> <books> <title>The Healthy Gourmet Cookbook</title> </books> </author> <author> <first_name>Beverly</first_name> <last_name>Bare Bueher</last_name> <books> <title>Cary Grant: A Bio-Bibliography</title> <title>Japanese Films</title> </books> </author> <author> <first_name>James P.</first_name> <last_name>Bateman</last_name> <books> <title>Illinois Land Use Law</title> </books> </author> </book_list> I then use this JavaScript code to read and display the data: > <script type="text/javascript"> if > (window.XMLHttpRequest) { > xhttp=new XMLHttpRequest(); } else > // Internet Explorer 5/6 { > xhttp=new > ActiveXObject("Microsoft.XMLHTTP"); > } xhttp.open("GET","books.xml",false); > xhttp.send(""); > xmlDoc=xhttp.responseXML; > > document.write("<table>"); var > x=xmlDoc.getElementsByTagName("author"); > for (i=0;i<x.length;i++) { > document.write("<tr><td>"); > document.write(x[i].getElementsByTagName("first_name")[0].childNodes[0].nodeValue); > document.write("&nbsp;"); > document.write(x[i].getElementsByTagName("last_name")[0].childNodes[0].nodeValue); > document.write("</td><td>"); > document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue); > document.write("</td></tr>"); } > document.write("</table>"); </script> The code works well except it only returns the first title element of each author. I somewhat understand why it's doing that, but I don't know how to nest another loop so when the script runs it displays all the titles for an author, not just the first. Whenever I try to nest a loop it breaks the entire script.

    Read the article

  • PHP - DOM class - numbered entities and encodings problem

    - by user343607
    Hi guys, I'm having some difficult with PHP DOM class. I am making a sitemap script, and I need the output of $doc-saveXML() to be like <?xml version="1.0" encoding="UTF-8"?> <root> <url> <loc>http://www.somesite.com/servi&#xE7;os/redesign</loc> </url> </root> or <?xml version="1.0" encoding="UTF-8"?> <root> <url> <loc>http://www.somesite.com/servi&#231;os/redesign</loc> </url> </root> but I am getting: <?xml version="1.0" encoding="UTF-8"?> <root> <url> <loc>http://www.somesite.com/servi&amp;#xE7;os/redesign</loc> </url> </root> This is the closet I could get, using a replace named to numbered entities function. I was also able to reproduce <?xml version="1.0" ?> <root> <url> <loc>http://www.somesite.com/servi&amp;#xE7;os/redesign</loc> </url> </root> But without the encoding specified. The best solution (the way I think the code should be written) would be: <?php $myArray = array(); // do some stuff to populate the with URL strings $doc = new DOMDocument('1.0', 'UTF-8'); // here we modify some property. Maybe is the answer I am looking for... $urlset = doc->createElement("urlset"); $urlset = $doc->appendChild($urlset); foreach($myArray as $address) { $url = $doc->createElement("url"); $url = $urlset->appendChild($url); $loc = $doc->createElement("loc"); $loc = $url->appendChild($loc); $valueContent = $doc->createTextNode($value); $valueContent = $loc->appendChild($address); } echo $doc->saveXML(); ?> Notes: Server response header contains charset as UTF-8; PHP script is saved in UTF-8; URLs read are UTF-8 strings; Above script contains encoding declaration on DOMDocument constructor, and does not use any convert functions, like htmlentities, urlencode, utf8_encode... I've tried changing the DOMDocument properties DOMDocument::$resolveExternals and DOMDocument::$substituteEntities values. None combinations worked. And yes, I know I can made all process without specifying the character set on DOMDocument constructor, dump string content into a variable and make a very simple string substitution with string replace functions. This works. But I would like to know where I am slipping, how can this be made using native API's and settings, or even if this is possible. Thanks in advance.

    Read the article

  • Retrieving information from DOM elements returned using ajax

    - by niczoom
    I am new(ish) to jQuery and am testing out the extraction of DOM element data using jQuery. Below, detailed on the firebug console I tried to extract data 10 different ways (from 1- to 10-) using data returned directly from the ajax request (rtnData). And then to compare, I wrapped (rtnData) in a div to make it a jQuery object, and stored it in $test, (var $test= $('<div/>').html(rtnData);) Displayed below in Firebug Console Output, I cant figure out is why 5- return's nothing and e- returns the center tag contents. Same with 8- and e-, they both look for #ticker div id but 8- returns nothing and e- returns the correct html?? Also when searching for h1 tag .text(), why does 10- return blank and j- return the correct data? Thanks, Nic. Use the following page to run the ajax request below in Firebug Console: http://www.liamharding.com/pgi/pgi.php jQuery code ran using Firebug Console: $.ajax({ url: 'pgiproxy.php', type: 'POST', dataType: 'html', data: ({ data : $("#formdata").serialize(), mode : "graph"}), success: function(rtnData){ console.log("0- ", rtnData); console.log("1- ", $('img', rtnData)); console.log("2- ", $('a', rtnData)); console.log("3- ", $('span.cr', rtnData)); console.log("4- ", $('span.cr', rtnData).html()); console.log("5- ", $('center', rtnData)); console.log("6- ", $('table', rtnData)); console.log("7- ", $('#ticker_data', rtnData)); console.log("8- ", $('#ticker', rtnData)); console.log("9- ", $('#last', rtnData)); console.log("10- ", $('h1', rtnData).text()); var $test= $('<div/>').html(rtnData); console.log("z- ", $test); console.log("a- ", $('img', $test)); console.log("b- ", $('a', $test)); console.log("c- ", $('span.cr', $test)); console.log("d- ", $('span.cr', $test).html()); console.log("e- ", $('center', $test)); console.log("f- ", $('table', $test)); console.log("g- ", $('#ticker_data', $test)); console.log("h- ", $('#ticker', $test)); console.log("i- ", $('#last', $test)); console.log("j- ", $('h1', $test).text()); }, error: function(){ alert('ERROR'); } }); Firebug Console Output: 1- jQuery(img#GnuPlotChart 624e4629...8946.gif) 2- jQuery(a.button javascri...eload();, a.button javascri...close();) 3- jQuery(span.cr) 4- <span class="tl"></span><span class="tr"></span><span class="bl"></span><span class="br"></span> 5- jQuery() 6- jQuery(table.rbox-table) 7- jQuery(div#ticker_data.rbox) 8- jQuery() 9- jQuery(th#last, td#last.num) 10- z- jQuery(div) a- jQuery(img#GnuPlotChart 624e4629...8946.gif) b- jQuery(a.button javascri...eload();, a.button javascri...close();) c- jQuery(span.cr) d- <span class="tl"></span><span class="tr"></span><span class="bl"></span><span class="br"></span> e- jQuery(center) f- jQuery(table.rbox-table, table) g- jQuery(div#ticker_data.rbox) h- jQuery(div#ticker) i- jQuery(th#last, td#last.num) j- Legacy Charts

    Read the article

  • PHP XML Strategy: Parsing DOM to fill "Bean"

    - by Mike
    I have a question concerning a good strategy on how to fill a data "bean" with data inside an xml file. The bean might look like this: class Person { var $id; var $forename = ""; var $surname = ""; var $bio = new Biography(); } class Biography { var $url = ""; var $id; } the xml subtree containing the info might look like this: <root> <!-- some more parent elements before node(s) of interest --> <person> <name pre="forename"> Foo </name> <name pre="surname"> Bar </name> <id> 1254 </id> <biography> <url> http://www.someurl.com </url> <id> 5488 </id> </biography> </person> </root> At the moment, I have one approach using DOMDocument. A method iterates over the entries and fills the bean by "remembering" the last node. I think thats not a good approach. What I have in mind is something like preconstructing some xpath expression(s) and then iterate over the subtrees/nodeLists. Return an array containing the beans as defined above eventually. However, it seems not to be possible reusing a subtree /DOMNode as DOMXPath constructor parameter. Has anyone of you encountered such a problem?

    Read the article

  • change image use javascript DOM

    - by user289346
    <html> <head> <script type="text/javascript"> var curimage = "cottage_small.jpg"; var curtext = "View large image"; function changeSrc() { if (curtext == "View large image"||curimage == "cottage_small.jpg") { document.getElementById("boldStuff").innerHTML = "View small image"; curtext="View small image"; document.getElementById("myImage")= "cottage_large.jpg"; curimage = "cottage_large.jpg"; } else { document.getElementById("boldStuff").innerHTML = "View large image"; curtext = "View large image"; document.getElementById("myImage")= "cottage_small.jpg"; curimage = "cottage_small.jpg"; } } </script> </head> <body> <!-- Your page here --> <h1> Pink Knoll Properties</h1> <h2> Single Family Homes</h2> <p> Cottage:<strong>$149,000</strong><br/> 2 bed, 1 bath, 1,189 square feet, 1.11 acres <br/><br/> <a href="#" onclick="changeSrc()"><b id="boldStuff" />View large image</a> </p> <p><img id="myImage" src="cottage_small.jpg" alt="Photo of a cottage" /></p> </body> </html> This is my coding I need to change the image and text the same time when I click it. I use LTS, it shows the line document.getElementById("myImage")= "cottage_large.jpg"; is a wrong number of arquments or invalid property assigment. Dose someone can help? Bianca

    Read the article

  • using document.createDocumentFragment() child dom elements that contain jQuery.data

    - by taber
    I want to use document.createDocumentFragment() to create an optimized collection of HTML elements that contain ".data" coming from jQuery (v 1.4.2), but I'm kind of stuck on how to get the data to surface from the HTML elements. Here's my code: var genres_html = document.createDocumentFragment(); $(xmlData).find('genres').each(function(i, node) { var genre = document.createElement('a'); $(genre).addClass('button') .attr('href', 'javascript:void(0)') .html( $(node).find('genreName:first').text() ) .data('genreData', { id: $(node).find('genreID:first').text() }); genres_html.appendChild( genre.cloneNode(true) ); }); $('#list').html(genres_html); // error: $('#list a:first').data('genreData') is null alert($('#list a:first').data('genreData').id); What am I doing wrong here? I suspect it's probably something with .cloneNode() not carrying over the data when the element is appended to the documentFragment. Sometimes there are tons of rows so I want to keep things pretty optimized, speed-wise. Thanks!

    Read the article

  • How to add dimensions to dynamic img elements

    - by Mohammad
    I use a Json call to get a list of image addresses, then I add them individually to a div like this. <div id="container"> <img src="A.jpg" alt="" /> <img src="B.jpg" alt="" /> ... </div> Unfortunately the image dimension is not part of the Json information but I do need them for later JQuery DOM interactivity. Do any of you JQuery geniuses know of a code that would flawlessly add the width and height to the individual image elements in the container after they load? I was thinking maybe the code could wait for the images to have a width bigger than 5px then add the new width and height to the element. But I wouldn't know how to go about that and make it work stably. Thank you so much!

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >