473,480 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Validate (X)HTML with custom tags with PHP DOM API

Gulzor
27 New Member
Hi,

I have defined a set of custom tags that I put among regular HTML tags. E.g.

<body>
<div id="regular_id">
<namespace:container id="something" type="article" />
</div>
</body>

At this time, I use PHP preg_* functions to parse the HTML file and trigger actions when I detect a tag that starts with the string "namespace:".

It works but I feel that I can do better with PHP DOM API :
Question : am I right on this ?

1) I would like to create either a DTD or a Schema for my custom tags and validate my HTML file against this.

I thought I could modify the official DTD for XHTML1.1 (transitional) and define my custom tags in it.

But then I might lost the benefits of namespaces since my custom tags will be merged with the regular HTML tags ?

2) I would like to use DOMDocument::getElementsByTagNameNS() to retrieve all my custom tags.

I don't know what's the best strategy.

All advises appreciated, code sample also ;-)

Thank you.
Dec 17 '08 #1
1 4419
Dormilich
8,658 Recognized Expert Moderator Expert
@Gulzor
there is no XHTML 1.1 transitional DTD (there's only one DTD for XHTML 1.1)

you can write your own DTD using the official one as a base or extend/redefine some of the official elements. the question is, if the browsers support that (a question to Dr. Google).

@Gulzor
you wouldn't. a DTD simply checks, if a document conforms to a given structure. not more, not less. the benefit of namespaces is not affected by a DTD.

@Gulzor
if these elements only trigger some server side action, remove them before you send the document to the browser. all that will be left is XHTML.

@Gulzor
sounds reasonable. code samples you'll find here

regards

note: IE doesn't support XHTML (i.e. it doesn't support the XHTML MIME type (and probably never will)) so make sure IE will be given an according document. (if you have XHTML 1.1 you probably know, what MIME type should be served (if not, see XHTML Media Types))
Dec 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3705
by: Chris | last post by:
Im hoping someone can help me understand why this works? Requirement: Navigate DOM through javascript to perform DHTML actions. Issue: GIANT html document, up to 4MB in size, thousands and...
47
10237
by: Chuck | last post by:
Is there any logical reason why one should convert if css is already being used? What possible, immediate, benefit would there be? I am at a loss to see what, pragmatic, difference it would make.
4
1814
by: Kenneth Keeley | last post by:
Hi All, How do I set Asp.Net to make the html code that it produces meet a W3C Standard. I would like to make all my pages meet XHTML 1.0 Strict standard if not at least meet XHTML 1.0...
3
6685
by: Sindbaad | last post by:
Hi, I have a requirement where in I need to parse and get all the HTML and custom specific tags from the HTML page. I'm using mshtml and vb.net. One way i thought off was to use the regex...
5
1847
by: Jim | last post by:
Can someone PLEASE tell me where I'm going wrong. I've stared at this page for 2 hours and still can't get it to validate on http://validator.w3.org/check. Page URL :...
9
6694
by: anupamjain | last post by:
Hi, After 2 weeks of search/hit-and-trial I finally thought to revert to the group to find solution to my problem.(something I should have done much earlier) This is the deal : On a JSP...
7
3253
by: Xah Lee | last post by:
Summary: when encountering ex as a unit in css, FireFox (and iCab) did not take into account the font-family. Detail: http://xahlee.org/js/ff_pre_ex.html Xah xah@xahlee.org ∑...
26
25555
by: webrod | last post by:
Hi, I have some php pages with a lot of HTML code. I am looking for a HTML validator tool (like TIDY). TIDY is not good enough with PHP tags (it removes a lot of php code). Do you have any...
0
569
by: Lars Eighner | last post by:
In our last episode, <004f629c$0$10265$c3e8da3@news.astraweb.com>, the lovely and talented mark4asp broadcast on comp.infosystems.www.authoring.html: I have not done this, not even on...
0
6911
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
7050
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7091
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...
1
6743
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.