473,386 Members | 1,795 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,386 software developers and data experts.

removing elements in namespace

Hi all,

I'm trying to clean up the output from Word that has been
pasted into a textarea. I'm purging much of the html (all
styles, attributes etc) and would also like to remove things
like vector graphics. To do this I want to simply drop all
elements (or their children) which are in any namespace other
than the default: all the microsoft-specific o:p, v:drawLine, etc
tags. But I can't persuade javascript to even see the namespaces!
I'm using IE5.5 (this needs to work on browsers that old, but no
older).

Has anyone done this before? Is there some simple step I might
be missing? Given an element variable, could you give me a line
or two of code just to display the namespace tag?

Thanks

Graham
Jul 23 '05 #1
2 1403


Graham wrote:

Has anyone done this before? Is there some simple step I might
be missing? Given an element variable, could you give me a line
or two of code just to display the namespace tag?


With IE 5 and later on Win elements have two properties
scopeName
giving the prefix and
tagUrn
giving the Namespace URN for example

<html lang="en"
xmlns:gods="http://example.com/2004/09/gods">
<head>
<title>scopeName and tagUrn</title>
<script type="text/javascript">
function testNamespaceProperties () {
var elements = document.body.all;
if (elements) {
var result = '';
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
result += 'tagName: ' + element.tagName + '; ';
result += 'scopeName: ' + element.scopeName + '; ';
result += 'tagUrn: ' + element.tagUrn;
result += '\r\n';
}
alert(result);
}
}

window.onload = function (evt) {
testNamespaceProperties();
};
</script>
</head>
<body>
<p id="p1">
This is a HTML paragraph.
</p>
<div>
<gods:GOD id="GOD">Kibo</gods:GOD>
</div>
</body>
</html>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2


Martin Honnen wrote:


Graham wrote:

Has anyone done this before? Is there some simple step I might
be missing? Given an element variable, could you give me a line
or two of code just to display the namespace tag?

With IE 5 and later on Win elements have two properties
scopeName
giving the prefix and
tagUrn
giving the Namespace URN


Documentation is here
http://msdn.microsoft.com/library/de...ies/tagurn.asp
http://msdn.microsoft.com/library/de.../scopename.asp

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3

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

Similar topics

6
by: Jason Heyes | last post by:
What is a good way of removing elements from std::vector so that the elements removed satisfy a predicate and end up stored in another std::vector. It seems as though the algorithm std::remove_if...
2
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this...
3
by: Keith Hill | last post by:
I am creating an XmlDocument in code and then using XmlTextWriter via doc.WriteTo(xwriter) to output the result to a text box. I have a root element that defines a default namespace. However, the...
2
by: Manoj G | last post by:
Hello, I believe there is no way to remove the default namespace declaration (For eg <DataSet xmlns="something">.... ) on an XmlNode object directly through DOM. So, what is the best way to...
11
by: EAI | last post by:
Hi All, I have a XML of the following form <?xml version="1.0"?> <xxxx xmlns="http://xxx.xxx.com"> .... </xxxx> When I try to read xml using SelectSingleNode, I am getting exception
6
by: Alien | last post by:
According to MSDN, removing elements invalidates only those iterators that had specifically pointed at the removed elements. But I tried following codes, and find that without the repeated...
6
by: Chris Chiasson | last post by:
Hi, After reading and experimenting for a several hours, I have this stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"...
3
by: Keith Patrick | last post by:
I'm doing some document merging where I want to bring in an XmlDocument and import its document element into another document deeper in its tree. However, when serializing my underlying objects,...
10
by: Andy Fish | last post by:
hi, I have an XSLT which is producing XML output. many of the nodes in the output tree contain namespace declarations for namespaces that are used in the source document even though they are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.