dom

Edit details from xml using DOM in java : problem in storing it into file.

I am using following code for storing edited data As : DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(new FileOutputStream(outputURL)); TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); transformer.transform(source, result); I am ...

Select elements based on class and element type

How can I select all elements within an HTML document with a specific class and specific element type? I'm trying to select all anchors with the class title loggedin from an HTML document (and then open them within the browser). These are within parragraphs with the class title. They are leafs in the following DOM tree: + body + div...

How to access a subset of XML data in Java when the XML data is too large to fit in memory?

What I would really like is a streaming API that works sort of like StAX, and sort of like DOM/JDom. It would be streaming in the sense that it would be very lazy and not read things in until needed. It would also be streaming in the sense that it would read everything forwards (but not backwards). Here's what code that used such an AP...

Outputting a DOM to HTML with &'s

I am trying to output a DOM that contains elements such as   to an html file, but it will show   in the output, which is obviously not desirable. My code is as follows Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "html"); Result re...

Adding and removing inputs via jQuery's remove(), but page gets slow, how to free memory?

I'm dynamically adding a lot of input fields through jQuery but the page gets really slow when reaching 200+ inputs (think of the page like a html excel sheet). This is fine really because this scenario is not very common. However, when I dynamically remove the input fields from the page using jQuery's htmlObj.remove() function, the page...

Can an Ajax call complete before the DOM is loaded?

I am grabbing data through a jQuery Ajax call, and displaying it on the page. I need to wait for both the DOM to load and for the Ajax call to complete before I can use the data to display it on the page. Can an Ajax call ever complete before the DOM has loaded? I'm just trying to determine where I need to put my method that will mani...

How facebook extracts the right thumbnail of a link?

Hi, I'm wondering how facebook extracts the right picture of the article from a link? they ignore any icons, ads images, or other not related images, & they gives you the right image? What technique/method they use? because i've tried to extract all images using a php regex but how to find the right one? Thanks ...

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

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(functi...

Positioning decorated series of div tags on screen using offset, DOM JQUERY RELATED

Hi, I am using JQuery to position a series of div tags which basically use a class inside of the tag which decorates the divs as bars. So the div is a green box based on its css specifications to the glass. I have a list of STARTING postions, a list of left coordiantes- for the starting points I wish to position my DIV say 556, 560, ...

jQuery: responding to click event of element added to document after page load

I am writing a page which uses a lot of in situ editing and updating using jQuery for AJAX. I have come accross a problem which can best be summarized by the workflow described below: Clicking on 'element1' on the page results in a jQuery AJAX POST Data is received in json format The data received in json format The received data is...

Storing information in the DOM?

Im making a small private message application in the form of a phone. Ten messages are shown at the time. And the list of messages are scrolled up/down by hiding them. Just how bad is it to use the DOM to store information in this way. My main goal for doing this is to reduce calls to the database. And instead of making a new call all t...

DOM: I can't access dynamically created elements. What's wrong.

I am creating a form with AJAX. The way I have created the form is by writing out the html form elements in the innerHTML of the div where I'm putting the form div.innerHTML += '&nbsp;<input type="text" name="day" id="eventDay" size="2" maxlength="2" value="'+response.day+'" />,'; div.innerHTML += '&nbsp;20<input type="text" name="year"...

How do I remove descendant elements from a jQuery wrapped set?

I'm a little confused about which jQuery method and/or selectors to use when trying to select an element, and then remove certain descendant elements from the wrapped set. For example, given the following HTML: <div id="article"> <div id="inset"> <ul> <li>This is bullet point #1.</li> <li>This is bullet point #2.</li>...

How do you access @font-face in the DOM (via Javascript)?

Hi I'm looking to access @font-face with Javascript. I assume it's somewhere in the DOM but where? I want to do this for @font-face feature detection. Thanks! ...

Firefox won't change image source

I'm trying to change an image in JavaScript+Prototype by changing the "src" attribute of the element. It works fine in IE, but not in Firefox. I don't get any errors and the script continues executing after this bit executes: var image = $('toggle'); image.setAttribute("src", "../images/icons/icon_minus.gif"); image.setAttribute("alt", ...

Dynamically generated form field loses value when new field is added

Hello! I am generating a dynamic fieldset with javascript. For adding fields, I use the following function (this function actually adds more than one field) //add test function addTest() { var location = document.getElementById('addTestLocation'); var num = document.getElementById('addTestCount'); var newnum = (document.ge...

Scriptaculous Autocomplete to activate when the page is loaded.

Is there a way to fire up Scriptaculous's Autocomplete to search with the default word from the inputfield when the page is loaded? Something like this? <input type="text" id="autocomplete" class="autocomplete_input" name="autocomplete_parameter" value="friends"/> <span id="indicator1" style="display: none"> loading </span> <div id="au...

naming domain objects in a social network

very general question related to the domain model: On social networks, people following you are called followers. People you follow are called ... ? any suggestions? ...

Element.replace() leaks DOM nodes

I'm trying to replace a DOM element (a div) using Prototype's Element.replace() operation. It seems to do the replacement OK, but leaks a single DOM node in the process. I checked this with sIEve; all but one of the existing DOM elements is freed by the innerHTML="" bit. This is in turn leaking memory, which I can't afford in a long-runn...

Using jQuery to gather all text nodes from a wrapped set, separated by spaces

I'm looking for a way to gather all of the text in a jQuery wrapped set, but I need to create spaces between sibling nodes that have no text nodes between them. For example, consider this HTML: <div> <ul> <li>List item #1.</li><li>List item #2.</li><li>List item #3.</li> </ul> </div> If I simply use jQuery's text() method to ...