473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

parse xhtml with xpath???

Hello

Can I parse an XHTML Document with XPath?

I tried the following expressions with the following XHTML Document with n
o result:
Removing the doctype and the namespace (xmlns) statemens I get the expected
result . Problem: I need the doctype and the namespace tags in my document.

Thank you
Sincerely Lore

Expressions: *********************************************
/html
/html/@xmlns
//p
/html/body/div/p[@id='USA']
XTHML-Dokument: ************************************************** *
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head></head>
<body>
<div>
<p id="USA">
Empire Burlesque<br/>
Bob Dylan<br/>
10.90
</p>
<p id="UK">
Hide your heart<br/>
Bonnie Tyler<br/>
10.0
</p>
<p id="GB">
Greatest Hits<br/>
Beatles<br/>
9.90
</p>
</div>
</body>
</html>
Apr 16 '06 #1
1 4360


Lore Leunoeg wrote:
Can I parse an XHTML Document with XPath?
Yes, XHTML is XML so you can select nodes in an XHTML document with XPath.
I tried the following expressions with the following XHTML Document with n
o result:
Removing the doctype and the namespace (xmlns) statemens I get the expected
result . Problem: I need the doctype and the namespace tags in my document.
To select nodes in a default namespace see
<http://www.faqts.com/knowledge_base/view.phtml/aid/34022/fid/616>

/html


You could simply do
/*
or
/*[local-name() = 'html']
but check the link above about the proper way to bind a prefix (e.g.
xhtml to the namespace URI http://www.w3.org/1999/xhtml) and to use
/xhtml:html
--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Barring | last post by:
Hi All, I am new to XPath stuff. I want parse XMLDocument with XPath and find out subset of information. If you look at following xml, for i.e how can i retrieve subset information such as...
26
by: Charles Law | last post by:
Does anyone have a regex pattern to parse HTML from a stream? I have a well structured file, where each line is of the form <sometag someattribute='attr'>text</sometag> for example <SPAN...
1
by: Daniel | last post by:
how to parse <?xml version="1.0" encoding="UTF-8"?> with xpath? is it possible?
14
by: Rob Meade | last post by:
Hi all, I'm working on a project where there are just under 1300 course files, these are HTML files - my problem is that I need to do more with the content of these pages - and the thought of...
5
by: js | last post by:
I have a textbox contains text in the format of "yyyy/MM/dd hh:mm:ss". I need to parse the text using System.DateTime.Parse() function with custom format. I got an error using the following code. ...
5
by: markbfernandez | last post by:
I have an "Update Customer" form that doesn't work as .xhtml. Here's where it stops working: <input type="text" name="ud_first" id="ud_first" value="<? echo "$first"?>" /> -------^ When the...
7
by: C.W.Holeman II | last post by:
For info on the context of my question see the end of this posting. From http://www.w3.org/TR/XHTMLplusMathMLplusSVG/: How can I validate the result of client-side XSLT transform which has...
11
by: Peter Pei | last post by:
One bad design about elementtree is that it has different ways parsing a string and a file, even worse they return different objects: 1) When you parse a file, you can simply call parse, which...
6
by: =?Utf-8?B?RGF2aWRN?= | last post by:
Hello, I have an XML file generated from a third party application that I would like to parse. Ideally, I plan on having a windows service setup to scan various folders for XML files and parse the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.