Questions tagged [domdocument]

DOMDocument refers to a class encapsulating the DOM (Document Object Model). Various languages and technologies use the name DOMDocument for this purpose, for example PHP, COM, C++, and ActiveX

If you are thinking of using this tag, then you might be looking for the Document Object Model tag:

In PHP, for example, the DOMDocument class represents an entire HTML or XML document and serves as the root of the document tree.

2749 questions
0
votes
1 answer

PHP DOM: doesnt load css stylies

I have this code which getting html code of page and than replace all the HREF attributes of the A' tag to redirect it to my site , than my site load the page and again redirect the links and so on...
homerun
  • 19,837
  • 15
  • 45
  • 70
0
votes
1 answer

Reading HTML with php giving wrong information

I am trying to get some data from http://itunes.apple.com/us/genre/ios-productivity/id6007?mt=8&letter=A&page=10#page using the below code. $some_link = http://itunes.apple.com/us/genre/ios-productivity/id6007?mt=8&letter=A&page=10#page; $content =…
Vish K
  • 127
  • 1
  • 2
  • 11
0
votes
1 answer

What is the SimpleXML version of this DOMDocument XML?

I understand that SimpleXML is far more efficient than DOMDocument. Any advice on how I would reform the below into a SimpleXML version? load( 'feedpage.xml' ); $Main = $doc->getElementsByTagName(…
user1183682
0
votes
2 answers

Get/filter table-row content from PHP

How do I get all the TITLE and LINKS reading from a file ? A sample content of the file below TITLE
Sourav
  • 17,065
  • 35
  • 101
  • 159
0
votes
1 answer

Can We use Array Element in DomDocument and nesting xpath?

I am using the following code $page_data=array();//$title_links is array having urls $nodearr=array(); foreach ($title_links as $b_url) { $page_data[]= mycurl($b_url);//my curl function, it is okay $dom2 = new…
Zaffar Saffee
  • 6,167
  • 5
  • 39
  • 77
0
votes
1 answer

Can we nest a DomDocument object in another DomDocument Object?

I got a simple question here, but it is confusing me a lot.. Can i nest a dom Document objective in another Dom Document object? My answer to the question is NO, should be one tree with child node , not a tree with child trees..It is only my answer…
Zaffar Saffee
  • 6,167
  • 5
  • 39
  • 77
0
votes
1 answer

How to turn off converting special characters to entities in DOMDocument?

I'm using the code as bellow to get the wanted content form HTML by DOMDocument, $subject = 'some html code'; $doc = new DOMDocument('1.0'); $doc->loadHTML($subject); $xpath = new DOMXpath($doc); $result =…
Jimmix
  • 5,644
  • 6
  • 44
  • 71
0
votes
4 answers

Better way to find an element within a element

I am looking a better method than "find" to find all the elements within an element:
Test
Test
Test …
emphaticsunshine
  • 3,725
  • 5
  • 32
  • 42
0
votes
1 answer

Parsing Dom element in sequence

i need to parse the following code
Zaffar Saffee
  • 6,167
  • 5
  • 39
  • 77
0
votes
1 answer

PHP: DOMNode::appendChild to an array of Elements

I am using DOMDocument to parse an XML file. I loop through the different Elements and see if any of them is missing and I fill an array with a createElement, with the error message. At the end I'm trying to appendChild that array but I always get…
Riki Lyng
  • 317
  • 4
  • 19
0
votes
4 answers

PHP - 'wrap' tag around any tag within a string

I need to take any img tag within a string, and add an a tag around it. E.g. $content= "Click for more info "; Would need to be replaced with "Click for more info
Scott Bowers
  • 1
  • 1
  • 1
0
votes
1 answer

Excluding tag in dom tree while running xpath query

I have a html structure like this..
0
votes
2 answers

using xpath to extract data by introducing ancestor in xpath query

i am using following code $doc = new DOMDocument(); $doc->strictErrorChecking = false; @$doc->loadHTML($data); $xpath = new DOMXPath($doc); //Select the parent node $categories…
Zaffar Saffee
  • 6,167
  • 5
  • 39
  • 77
0
votes
1 answer

writing CVS file using array and dom document in php

i am using this code to scrap the amazon.com $ch = curl_init(); // create a new cURL…
Zaffar Saffee
  • 6,167
  • 5
  • 39
  • 77
0
votes
1 answer

How to break down and parse specific Wikipedia text

I'm have the following working example to retrieve a specific Wikipedia page that returns a SimpleXMLElement Object: ini_set('user_agent', 'michael@example.com'); $doc = New…
Michael Pasqualone
  • 2,027
  • 2
  • 15
  • 23