dom

Creating a DOMDocument from a DOMNode in PHP

I get an XML string from a certain source. I create a DOMDocument object and load the XML string into it (with DOMDocument::loadXML()). Then I navigate through the XML doc using various methods (e.g. DOMXPath), until I find the node (a DOMNode, of course) that I want. This node has a bunch of descendants, and I want to take that entire...

how can I retrieve an html document from a url from javascript?

Hi, I have a url and I want to retrieve the html dom generated when going to the url (all the code for the page) in a javascript variable. How can I do this? I'm guessing an html get or post? Can anyone give an example with jQuery? Every time I do a $.get or $.post like this: $.get("http://www.google.ca", function(result) { alert(res...

How to check in Javascript if one element is a child of another

Hello, How can I check if one DOM element is a child of another DOM element? Are there any built in methods for this? For example, something like: if (element1.hasChild(element2)) or if (element2.hasParent(element1)) If not then any ideas how to do this? It also needs to be cross browser. I should also mention that the child cou...

Firefox Or JavaScript, count the DOM

I'm sure this is simple but I have no idea how to do it. How do i count the amount of DOM elements in my HTML page? I wanted to do this in a userscript or bookmarklet but i have no idea how to start! ...

Why Does DOM Change Encoding?

$string = file_get_contents('http://example.com'); if ('UTF-8' === mb_detect_encoding($string)) { $dom = new DOMDocument(); // hack to preserve UTF-8 characters $dom->loadHTML('<?xml encoding="UTF-8">' . $string); $dom->preserveWhiteSpace = false; $dom->encoding = 'UTF-8'; $body = $dom->getElementsByTagName('body...

PHP DOM XML - Create Multiple NameSpace Addtributes?

Guys, I'm working on some PHP to create XML from a database using the DOM extension. Basically, I need to create a NameSpace and add 3 attributes to it: <NameSpaceName xmlns="http://xxx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xxx"&gt; The full code i've written is below: include_onc...

How to get IE6 to recognize inserted DOM elements via jQuery insertAfter()

I've got a jquery ajax function that polls the database server to see if there are new records. If so, it inserts the new records (with unique IDs) at the top of the record list using the following: $(new_records).insertAfter('#div_at_top_of_page'); This works fine, even in IE6. However, each inserted record has a secondary ajax fun...

How to access a Container Node as a Node List for a custom dojo/dijit Widget

I am trying to create a custom Templated Widget in dojo. I need to do some manipulation of the containerNode of the template and want to use the node as a dojo.NodeList. I cannot seem to get things to function like I want. For example, I need to be able to "push/pop/shift/unshift" children from the containerNode. If I do the followin...

JS: Detecting wrapped inline elements?

Hello, I have a indefinite amount of in-line elements being output. Now, depending on browser width, some elements will, of course, wrap to a new line. Is it possible to detect and single out these rows of elements or does the dom just see it as one large line? Thanks for the help!! EDIT: Trying to detect wrapped elements via offset h...

Best way to reorder dom elements based on json data

Once I create dom elements base on json data with jtemplates, what is the best way to reorder those elements based on changes to the json data (sorting, filtering, etc.). ...

childNodes.length 0 in Chrome / Correct In IE & FF

I have a div with children that I need to crawl looking for specific links. The HTML looks like so: <div id="ctl00_LeftNav"> <h3> <a href="../App_Templates/#" rel="0">Menu 1</a></h3> <div> <p> <span> <div style="padding-left: 0px; font-weight: bold;"> <a href="javas...

PHP MYSQL to XML - Efficient File Generation

Hi there, I run a price comparison data engine, and as we are collecting so much data im running into pretty serious performance issues. We generate various XML files, one per product and within the product data is each Online shop we grab data from, with their price, link, description, etc. We have multiple feed parsers/scrapers which ...

Moving a large set of HTML objects on the page and rebinding events with jQuery

I have a DIV with many elements that are all clickable. Each one with it's own unique event. This DIV has a "docked" mode where it shows in some other place and layout on the page, when the mode is toggled. I have to note that my main target browser is IE8. Many of the problems I'm facing here (SSSLLLLLOOOOWWWWW) just go away when I ...

Rotate webpage via code?

I'm hoping that there's a relatively simple way to rotate a webpage a little bit, 30 degrees or so, while still leaving it fully functional and usable. I completely control the page, and can modify it to make this easier if needed. I'd rather not re-write the whole thing in SVG, though, but perhaps javascript and canvas will work? Is ...

Serialize a DOM range

Hi, is there any standard/easy way to serialize a DOM Range (and the IE equivalent) with java script. The motivation is to store the current selection for a document together with its HTML code. I thought of using XPath for it, but before I start to reinventing the wheel maybe there is something already working available and I just ...

SAXReader not re-ecape characters

I'm reading a XML file with dom4j. The file looks like this: ... <Field>&#13;&#10; hello, world...</Field> ... I read the file with SAXReader into a Document. When I use getText() on a the node I obtain the followin String: \r\n hello, world... I do some processing and then write another file using asXml(). But the characters are ...

Auto-Scroll in FireFox

My application is a Live chat. I have a Div to wrap the messages, each message is a div, so, after a few messages my DOM looks like this : <div id = "divChatHistory"> <div id = "msg1> Message number one </div> <div id = "msg2> Message number two </div> <div id = "msg3> Message number three </div> // ... </div> Now a need t...

Edit HTML in IE Developer Toolbar

Is it possible to edit HTML, add nodes, etc. using IE Developer Toolbar? ...

How do I insert HTML into a PHP DOM object?

Hello, I am using PHP's DOM object to create HTML pages for my website. This works great for my head, however since I will be entering a lot of HTML into the body (not via DOM). I would think I would need to use DOM->createElement($bodyHTML) to add my HTML from my site to the DOM object, However DON->createElement seems to parse all HTM...

parsing HTML with Firefox

uri = 'http://www.nytimes.com/'; searchuri = 'http://www.google.com/search?'; searchuri += 'q='+ encodeURIComponent(uri) +'&btnG=Search+Directory&hl=en&cat=gwd%2FTop'; req = new XMLHttpRequest(); req.open('GET', searchuri, true); req.onreadystatechange = function (aEvt) { if (req.readyState == 4) { if(req.status == 200) { ...