Question: I have some code for get html table result tracking from this site http://www.jne.co.id/tarif.php i try to create from my localhost this code: i need to get table html with class»table_style tracking», see this image Image EDIT: i just need get html with class tracking, not string inside html. Question: I’m currently using nodeValue to give me HTML output, however it is stripping the HTML code and just giving me plain text.
PHP — How I can get innerHTML on an element?
I am novice in PHP. I have javascript functions for adding , removing and moving favorites (DOM Manipulation only). When I refresh the page this favorites are cleared. I need:
1.Get innerHTML on current (DOM manipulated) favorites DIV element (where favorites are).
2.Store the HTML in PHP varable (i need ‘php’ varable cuz i will insert the value in DB).
I would do one of the following, depending on what you’re really trying to accomplish.
Do an ajax post to your PHP code that contains the information required to save the favorite entries (i.e. just the ID, URL and name, not the actual HTML).
Maintain a few hidden form fields that hold the information required to save the favorite entries. This will give you access to the data from PHP with the form is submitted (assuming a form is involved).
Note that I don’t think what you really want is to get the innerHTML of elements from your PHP code. You probably want to find a way to represent that information in a way that can more easily be sent to your server-side code.
var v = document.getElementsByClassName('minID')[0].innerHTML; // select whatever $.cookie("something", v, < expires: 5 >); // set cookie
Html — Using PHP to get DOM Element, 2 Answers Sorted by: 22 getElementsByTagName returns you a list of elements, so first you need to loop through the …
How to extract innerHTML using the PHP Dom [duplicate]
I’m currently using nodeValue to give me HTML output, however it is stripping the HTML code and just giving me plain text. Does anyone know how I can modify my code to give me the inner HTML of an element by using it’s ID?
function getContent($url, $id)< // This first section gets the HTML stuff using a URL $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); $html = curl_exec($ch); curl_close($ch); // This second section analyses the HTML and outputs it $newDom = new domDocument; $newDom->loadHTML($html); $newDom->preserveWhiteSpace = false; $newDom->validateOnParse = true; $sections = $newDom->getElementById($id)->nodeValue; echo $sections; >
Dom — How to get innerHTML of each element in a node, document |> Document.querySelectorAll(«.item») |> NodeList.toArray |> Array.iter(node => node |> Element.ofNode |> Js.Option.getExn |> Element.innerHTML |> Js.log ); It also has to be said that direct DOM manipulation isn’t a great fit for Reason, or any statically typed functional language for that …
Getting the Inner HTML of a DomElement in PHP [duplicate]
What’s the simplest way to get the innerHTML (tags and all) of a DOMElement using PHP’s DOM functions?
Php — How to get innerHTML of DOMNode?, What function do you use to get innerHTML of a given DOMNode in the PHP DOM implementation? Can someone give reliable solution? Of course outerHTML will do too. Stack Overflow. About ; Products For Teams; Stack Overflow Public questions & answers; Stack Overflow for Teams Where …
How to use simple html dom get inner html [duplicate]
I have some code for get html table result tracking from this site http://www.jne.co.id/tarif.php
i try to create from my localhost this code:
urlencode($_POST['origin_code']), 'dest_code' => urlencode($_POST['dest_code']), 'weight' => urlencode($_POST['weight']), 'g-recaptcha-response' => urlencode($_POST['g-recaptcha-response']), ); $fields_string = ''; //url-ify the data for the POST foreach($fields as $key=>$value) < $fields_string .= $key.'='.$value.'&'; >rtrim($fields_string, '&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //execute post $result = curl_exec($ch); $string = $result;//htmlentities($result); //close connection curl_close($ch); // Create a DOM object $html_base = new simple_html_dom(); // Load HTML from a string $html_base->load($string); $str = $html_base->find('.tracking'); echo $str; $html_base->clear(); unset($html_base); > ?>
i need to get table html with class»table_style tracking», see this image
Nama Layanan
Jenis Kiriman
Tarif
ETD(Estimates Days)
OKE
Dokumen / Paket
Rp. 10.000
2 - 3 D
REG
Dokumen / Paket
Rp. 11.000
1 - 2 D
YES
Dokumen / Paket
Rp. 22.000
1 - 1 D
SPS
Dokumen / Paket
Rp. 403.000
$items = str_get_html($html); $count = 0; $country = $items->find('.category-label span', 0)->text(); // first element by index 0
How to extract innerHTML using the PHP Dom, Browse other questions tagged php dom innerhtml nodevalue or ask your own question. The Overflow Blog Skills that pay the bills for software developers (Ep. 460)
Here’s another approach based on this comment by Drupella on php.net, that worked well for my project. It defines the innerHTML() by creating a new DOMDocument , importing and appending to it the target node, instead of explicitly iterating over child nodes.
Old query, but there is a built-in method to do that. Just pass the target node to DomDocument->saveHtml() .
$html = '
ciao questa ГЁ una prova.
'; $dom = new DomDocument($html); @$dom->loadHTML($html); $xpath = new DOMXPath($dom); $node = $xpath->query('.//div/*'); // with * you get inner html without surrounding div tag; without * you get inner html with surrounding div tag $innerHtml = $dom->saveHtml($node); var_dump($innerHtml);
Output:
ciao questa ГЁ una prova.
Answer
Solution:
For people who want to get the HTML from XPath query, here is my version:
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
About the technologies asked in this question
PHP
PHP (from the English Hypertext Preprocessor — hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites. The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license. https://www.php.net/
HTML
HTML (English «hyper text markup language» — hypertext markup language) is a special markup language that is used to create sites on the Internet. Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone. https://www.w3.org/html/
Welcome to programmierfrage.com
programmierfrage.com is a question and answer site for professional web developers, programming enthusiasts and website builders. Site created and operated by the community. Together with you, we create a free library of detailed answers to any question on programming, web development, website creation and website administration.
Get answers to specific questions
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Help Others Solve Their Issues
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.