dom

How to escape HTML.

I have a string which contains HTML text. I need to escape just the strings and not tags. For example, I have string which contains, <ul class="main_nav"> <li> <a class="className1" id="idValue1" tabindex="2">Test & Sample</a> </li> <li> <a class="className2" id="idValue2" tabindex="2">Test & Sample2</a> </li> </ul> How to escape just...

Memory Issues When DOM Parsing A Large XML File on Android Devices

Hey awesome SO users, I have an Android application that parses an XML file for users and displays results in a much more mobile friendly format. The app works great for most users, but some users have lots and lots of data and the app crashes on them because it runs out of memory. Is there any way I have a DOM style XML parser quit pa...

PHP DOMElement::getElementsByTagName - Anyway to get just the immediate matching children?

Hi All, is there a way to retrieve only the immediate children found by a call to DOMElement::getElementsByTagName? For example, I have an XML document that has a category element. That category element has sub category elements (which have the same structure), like: <category> <id>1</id> <name>Top Level Category Name</name> ...

Problem using form builder & DOM manipulation in Rails with multiple levels of nested partials

I'm having a problem using nested partials with dynamic form builder code (from the "complex form example" code on github) in Rails. I have my top level view "new" (where I attempt to generate the template): <% form_for (@transaction_group) do |txngroup_form| %> <%= txngroup_form.error_messages %> <% content_for :jstemplates do -%> <%= ...

PHP DOM element string breaks with strtotime() or preg_replace()

I'm using PHP to get XML from an API (Say that 3 times fast). I'm getting all of the correct strings returned from all of the data. The problem comes when I try to reformat the time string with the following two methods: $dataset = $xmlDoc->getElementsByTagName( "Class" ); foreach( $dataset as $row ) { $xmlStartTimes = $row->getEl...

(PHP5) Extracting a title tag and RSS feed address from HTML using PHP DOM or Regex

Hi there, I'd like to get the title tag and RSS feed address (if there is one) from a given URL, but the method(s) I've used so far just aren't working at all. I've managed to get the title tag by using preg_match and a regular expression, but I can't seem to get anywhere with getting the RSS feed address. ($webContent holds the HTML o...

Transform RSS-Feed into another "standard" XML-Format with PHP

Hey friends, quick question: I need to transform a default RSS Structure into another XML-format. The RSS File is like.... <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> <title>Name des RSS Feed</title> <description>Feed Beschreibung</description> <language>de</lang...

Dom Element onclick (MooTools :: optionally)

Consider the following example: function async_callback(array1, array2, array3) { // All arrays are equal length for(var i = 0; i < array1.length; i++) { var myElement = new Element('div', { 'id': 'dvMy' + i, 'events': { 'click': function() { SomeFunction(array1[i], array2[i], array3[i] } }}); $(document).appendChild(myElem...

php DOM, get values from xml document, php xml

I'm trying to get some information (itemID, title, price and mileage) for multiple listings from eBay website using their api. So far I got this up I've saved the document as .xml file using PHP cUrl and now I need to get/extract the values(itemID, title, price and mileage) into arrays and store them in database. Unfortunately I neve...

Is there a difference between placing JavaScript calls in $(document).ready(function(){ and placing them in HTML?

Is there a difference, performance or efficiency wise, between placing javascript calls such as blur, onclick etc. in $(document).ready(function(){ as opposed to placing them in HTML? Thanks! ...

HTML where will the focus go next if I press tab?

Hi all, Is there some way of knowing where will the focus jump to when the tab key key will be pressed and certain element has the focus? I am thinking on something to be used this way: var nextElement = whereWillFocusJumpTo(currentElement); Thanks! ...

Copy all childNodes to an other element. In javascript native way.

Hello I have to change "unknown" contents of XML. The structure and content itself is valid. Original <blabla foo="bar"> <aa>asas</aa> <ff> <cc> <dd /> </cc> </ff> <gg attr2="2"> </gg> ... ... </blabla> becomes <blabla foo="bar"> <magic> <aa>asas</aa> <ff> ...

a question of javascript DOM functions in IE 6

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test</title> </head> <body> <div id="test"> </div> <script type="text/javas...

Plugin for Opera. DOM-tree modification.

I want to create a plugin for opera that modifies tha DOM-tree after the page have been loaded. Does opera have an appropriate plugin API? ...

How to inject a javascript function from one page into another

Alright, let me preface this by saying that I have little programming experience, so I apologize if my explanation belies some serious ignorance. I've always wanted to learn certain tricks but I can never find any tutorials. Here's the deal: There's a website that gives you various science questions and grades the input. For each que...

javascript - dom searching for id returns an error - how to handle?

for (i=1; i<=4; i++) { try { timer = document.getElementById("timer"+i).parentNode.parentNode.parentNode.childNodes[1].childNodes[0].childNodes[0].className; } catch(e) { FM_log("aguardaReforcos()", "ERRO - timer"+i); } ... I have to it this way with try because otherwise I get...

jQuery: dom insertion selector problem after .get

HI Volks, here is my code block which I want to replace by the ajax respond: <div class="results"> <span id="like9"> <a class="like" rel="ajax.php?id=9" href="#">klick</a> </span> </div> this is how I observe the ajax link: $(document).ready(function() { $('.results .like').click(function() { params = getUrlVars($(t...

Making the nodes to ignore namespaces (prefixes) after changing XML structure. PHP DOMDocument

Hello. Original XML (myfile.xml) <?xml version="1.0" encoding="UTF-8" standalone="no"?> <blabla xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:blabla="http://www.w3.org/2000/blabla" xmlns="http://www.w3.org/2000/b...

Best practice for trapping certain keyCodes in onkeypress in Javascript

I'm somewhat curious about the "best practices" when it comes to trapping the ENTER key in an html input tag. In IE, it's easy. window.event.keyCode will be 13 when enter is pressed and it's pretty straight forward. In all other browsers, an arguments object is passed into the function. However, this seems to basically force you to l...

Javascript Closure and DOM Builder

I am making a DOM builder which I have working succesfully but now I am trying to assign some shorthand functions so that div() -> e("div") Here is my code: //assign these objects to a namespace, defaults to window (function(parent) { /** * Creates string of element * @param tag The element to add * @param options An object of attribu...