Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-06-07 00:56:56
Point:125 Replies:4 POST_ID:828317USER_ID:11059
Topic:
PHP Scripting Language;Hypertext Markup Language (HTML);Web Languages/Standards
Dear Expert,
From following exmplle of example.php which is easily to extract xml data from example.xlm file, it just
use getElementsByTagName('file') in order to get the image file name in example.xml (example.png).
But how I convert HTML web paga data into XML format, because I would like to extract HTML data
by PHP coding.
The problem-1 : Converting HTML to XMLformat
THe problem-2, I use other way, I directly extract HTML data using example.php program and replace example.xml by mywebpage.html, and using getElementsByTagName('SPAN') to extract SPAN tag data
which is "116.200" but finaly it shown out no any result and no any error. It seem the php code
could not find out where SPAN tag is.
Question-1 Could you help on this and give some code hit to extract the tag <Span class="neg_bold">.nodevalue ?
THanks & Br
Duncan
mywebpage.html code is as follows:
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<span class="neg bold">116.200</span>
</body>
</html>
From following exmplle of example.php which is easily to extract xml data from example.xlm file, it just
use getElementsByTagName('file') in order to get the image file name in example.xml (example.png).
But how I convert HTML web paga data into XML format, because I would like to extract HTML data
by PHP coding.
The problem-1 : Converting HTML to XMLformat
THe problem-2, I use other way, I directly extract HTML data using example.php program and replace example.xml by mywebpage.html, and using getElementsByTagName('SPAN') to extract SPAN tag data
which is "116.200" but finaly it shown out no any result and no any error. It seem the php code
could not find out where SPAN tag is.
Question-1 Could you help on this and give some code hit to extract the tag <Span class="neg_bold">.nodevalue ?
THanks & Br
Duncan
mywebpage.html code is as follows:
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<span class="neg bold">116.200</span>
</body>
</html>
example.php
?php
$dom = new DomDocument();
$dom->prevservWhiteSpace = false;
if (!@$dom->load("example.xml")) {
echo "example.xml doesn't exist!";
return;
}
$imageList = $dom->getElementsByTagName('file');
$imageCnt = $imageList->length;
for ($idx = 0; $idx < $imageCnt; $idx++) {
print $imageList->item($idx)->nodeValue . "";
}
?>
?php
$dom = new DomDocument();
$dom->prevservWhiteSpace = false;
if (!@$dom->load("example.xml")) {
echo "example.xml doesn't exist!";
return;
}
$imageList = $dom->getElementsByTagName('file');
$imageCnt = $imageList->length;
for ($idx = 0; $idx < $imageCnt; $idx++) {
print $imageList->item($idx)->nodeValue . "";
}
?>
example.xml
<?xml version="1.0" encoding="utf-8" ?>
<root>
<box>
<file>example.png</file>
</box>
<content>
<item>
<image><file>example2.png</file></image>
<caption>The above image is an example</caption>
</item>
</content>
</root>
<?xml version="1.0" encoding="utf-8" ?>
<root>
<box>
<file>example.png</file>
</box>
<content>
<item>
<image><file>example2.png</file></image>
<caption>The above image is an example</caption>
</item>
</content>
</root>
Expert: Ian Gough replied at 2024-06-07 04:14:31
Anytime always happy to help,
All the best,
Ian
Author: duncanb7 replied at 2024-06-07 04:11:08
THnaks for your quick reply, jangough7
Author: duncanb7 replied at 2024-06-07 04:10:28
That is what I want the syntax
Accepted Solution
Expert: Ian Gough replied at 2024-06-07 02:15:39
125 points GOOD
http://w-shadow.com/blog/2009/10/20/how-to-extract-html-tags-and-their-attributes-with-php/
Might help you out,
Ian