473,671 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extracting the XHTML "lang" parameter.

Hi All,

I am toying with the idea of making a GreaseMonkey script, or similar
(depending on how far out of my comfort zone I am willing to venture),
which would translate a page automatically.

In order to trigger that script and pass the correct variable to the
translator, I am looking for a way to extract certain details from the
current page.

One of the pages I am looking at is XHTML, and I am wanting to extract
the "lang" (or maybe the "xml:lang") from the page.
In the source it is shown like this:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de"
dir="ltr">

How would I reference that in JavaScript?

Any assistance or references that you may provide would be appreciated.

Luke

Sep 21 '05 #1
1 1786


lu*****@gmail.c om wrote:

One of the pages I am looking at is XHTML, and I am wanting to extract
the "lang" (or maybe the "xml:lang") from the page.
In the source it is shown like this:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de"
dir="ltr">

How would I reference that in JavaScript?


It depends on whether the document is parsed by an HTML parser or an XML
parser, if it is parsed by an HTML parser then
document.docume ntElement.getAt tribute('lang')
document.docume ntElement.getAt tribute('xml:la ng')
should do.
If it is parsed by an XML parser then for the lang attribute it should be
document.docume ntElement.getAt tribute('lang')
too, for the xml:lang attribute you need getAttributeNS as in the following

document.docume ntElement.getAt tributeNS('http ://www.w3.org/XML/1998/namespace',
'lang')
That way in an XHTML document served as application/xhtml+xml both
Mozilla (tested with 1.7) as well as Opera (tested with 8.50) give the
value of the xml:lang attribute.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 21 '05 #2

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

Similar topics

0
1618
by: Pedro Hernandez | last post by:
Hello! I have some (many) text files produced on windows system that I need to process a bit, so I wrote a perl script to do the job. The files contains characters used in Spanish (e.g. ó, é, ñ) and they doesn't come out right. I use RedHat 8 and it is installed with Spanish locale. LANG is "es_ES.UTF-8".
2
6240
by: Genzo | last post by:
Hi all, was wondering if anyone might have knowledge on this. am testing with Opera 7.11. essentially whenever i try to use the substring "&lang=" in any string value in javascript, and try to print it out, the "&lang" gets converted into some strange character. i.e., just try: alert ("heyhey&lang=blahblah");
6
22253
by: Zhang Weiwu | last post by:
Hello. I am working with a php software project, in it (www.egroupware.org) Chinese simplified locate is "zh" while Traditional Chinese "tw". I wish to send correct language attribute in http header, I found "zh" is not standard. I found this line in apache2's default httpd.conf # Simplified Chinese (zh-CN) AddLanguage zh-CN .zh-cn
2
1346
by: santa19992000 | last post by:
Guys: Can somebody suggest a "C lang" project with pointers and linked lits for beginner?. Also is there anywahere I can find some C projects?. Thanks in advance.
37
4179
by: Jan Wagner | last post by:
Hi, can't figure this one out, what's the CSS way to specify the language? In HTML it would be simply an lang="xx" attribute, or XHTML xml:lang="xx", but, how about in CSS? This would be required for a screen reader (text to speech) for accessibility, to help the reader software use the correct presentation method (e.g. correct language module).
0
8483
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8824
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8603
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8673
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7444
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6236
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.