domelement

Is there a better way to change a DOMElement->tagName property in php?

Hi all, I just ran into this building a Textbox control for my MVC framework, where just before finalizing the whole document I call PreRender on everything that inherits from ServerTag (which in turn inherits from DOMElement). The only way i have found to change a DOMElement derived object's tagName is to replace it with a new one wit...

How can I change the name of an element in DOM?

Hello, In PHP with DOM, I have a DomElement object which represents an <identity/> element. I have one case where I need to change this so its element name is <person/>, but keep the same child elements and attributes. What would be the simplest way of changing an element name of a DomElement and keeping its children and attributes? ...

JQuery - Hardcoding HTML in Javascript - Is there a better way to dynamically create dom elements?

I have a lot of messages, and raw HTML that I hard code in my javascript code, such as: var subjectId = $(subject).attr('subjectId'); var subjectName = $(subject).attr('subjectName'); var html = "<table id='invitations' class='invitations' width='100%'><tbody>"; $(subject).find('group').each( function() { var groupId = $(this)...

PHP XML node deletion

i have an XML file with large number of tags. it has more than 2000 tag here and there. i want to delete all that htmlText Tag and save it as a new xml. how cani do that in PHP??? here is the code tht iam using $remove = $doc->getElementsByTagName('htmlText'); $doc->removeChild($remove); ...

Is there a way to get all of a DOMElement's attributes?

I'm reading some XML with PHP and currently using the DOMDocument class to do so. I need a way to grab the names and values of a tag's (instance of DOMElement) attributes, without knowing beforehand what any of them are. The documentation doesn't seem to offer anything like this. I know that I can get an attribute's value if I have its n...

SHDocVw insert element in document.body?

Hi, I am trying to inject html and js into an IE from a bho. To get the body I use: Code: public static SHDocVw.WebBrowser webBrowser; HTMLDocument document = (HTMLDocument)webBrowser.Document; IHTMLElement body = (IHTMLElement)document.body; My idea was to use body.appendChild but that will only work for the webbrowser control and no...

DOMElement cloning and appending: 'Wrong Document Error'

There's something I don't fully understand about node cloning with the PHP's DOM api. Here's a sample file that quickly duplicates the issue I'm coming across. $doc = new DOMDocument( '1.0', 'UTF-8' ); $root = $doc->createElement( 'root' ); // This doesn't work either $root = new DOMElement( 'root' ); $doc->appendChild( $root ); $doc...

Not finding elements using getElementsByTagName() using DomDocument

I'm trying to loop through multiple <LineItemInfo> products contained within a <LineItems> within XML I'm parsing to pull product Ids out and send emails and do other actions for each product. The problem is that it's not returning anything. I've verified that the XML data is valid and it does contain the necessary components. $itemLi...

jQuery - returning $(this) DOM Element

Hello, i'm using DD_Belated.png to save all IE6 users from seeing the madness of unsupported png. However, this great script takes either selector or DOM Element as parameter to it's only function to do it's magic and return working PNG to IE6. Me, being lazy programmer, did something like this: $("img[src$=png], #search").each ( fu...

PHP DOMDocument replace DOMElement child with HTML string

Using PHP I'm attempting to take an HTML string passed from a WYSIWYG editor and replace the children of an element inside of a preloaded HTML document with the new HTML. So far I'm loading the document identifying the element I want to change by ID but the process to convert an HTML to something that can be placed inside a DOMElement i...

PHP: DomElement->getAttribute

How can I take all the attribute of an element? Like on my example below I can only get one at a time, I want to pull out all of the anchor tag's attribute. $dom = new DOMDocument(); @$dom->loadHTML(http://www.example.com); $a = $dom->getElementsByTagName("a"); echo $a->getAttribute('href'); thanks! ...

Extend DOMElement object

How could I extend objects provided with Document Object Model? Seems that there is no way according to this issue. class Application_Model_XmlSchema extends DOMElement { const ELEMENT_NAME = 'schema'; /** * @var DOMElement */ private $_schema; /** * @param DOMDocument $document * @return void ...

how to handle DOM in PHP

my PHP code $dom = new DOMDocument(); @$dom->loadHTML($file); $xpath = new DOMXPath($dom); $tags = $xpath->query('//div[@class="text"]'); foreach ($tags as $tag) { echo $tag->textContent; } what i'm trying to do here is to get the content of the div that has class 'text' but the problem when i loop and echo the results i only ge...

How do I display a DOMElement?

I'm using readability's code to extract HTML from a web page. How do I display it on a page? $content = grabArticle($webpage); echo $content; ERROR => Object of class DOMElement could not be converted to string... ...

Get notified when objective-c dom updates are ready initiated from webview

I am programmatically updating the DOM on a WebKit webview via DOMElement objects - for complex UI, there is usually a javascript component to any element that I add. This begs the need to be notified when the updates complete -- is there any such event? I know regular divs dont fire an onload or onready event, correct? The other assumpt...

Get a reference to a Canvas element from its context?

In one part of my code, I call getContext('2d') on a canvas element to produce a CanvasRenderingContext2D object. That object goes on to get passed around a fair bit from function to function, and at a later point in the code it'd be handy to be able to get a reference to the original canvas dom element that produced a given context. I ...

OOP - Extending DOMElement in PHP with registerNodeClass

registerNodeClass is great for extending the various DOMNode-based DOM classes in PHP, but I need to go one level deeper. I've created an extDOMElement that extends DOMElement. This works great with registerNodeClass, but I would like to have something that works more like this: registerNodeClass("DOMElement->nodeName='XYZ'", 'extDOMXYZ...

Accessing properties of html element inside javascript function using $(this) gives undefined

I am calling a function test() on an anchor tag like this:- <a class="link" onclick="test();">Hello</a> And I am trying to access the class of the anchor inside the function test():- function test() { alert($(this).attr("class")); } But this alerts undefined. I know that calling onclick=test(this); instead and having the followin...