473,657 Members | 2,316 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1429


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="htt p://example.com/2004/09/gods">
<head>
<title>scopeNam e and tagUrn</title>
<script type="text/javascript">
function testNamespacePr operties () {
var elements = document.body.a ll;
if (elements) {
var result = '';
for (var i = 0; i < elements.length ; i++) {
var element = elements[i];
result += 'tagName: ' + element.tagName + '; ';
result += 'scopeName: ' + element.scopeNa me + '; ';
result += 'tagUrn: ' + element.tagUrn;
result += '\r\n';
}
alert(result);
}
}

window.onload = function (evt) {
testNamespacePr operties();
};
</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
8015
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 only achieves half the job. Here is how I would use std::remove_if to remove elements from std::vector based on predicate: v.erase(std::remove_if(v.begin(), v.end(), pred), v.end()); After that line is executed I cannot get back the elements...
2
10686
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 attribute and remove the containing node (and child nodes) if it has a certain value. I'm able to find the attributes using an XmlTextReader. Once found, can someone help me get the XPath at that point? I would then use this to remove the node from...
3
7136
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 sub-elements are created without any namespaces like so: XmlElement elem = doc.CreateElement("Foo"); root.AppendChild(elem); but in the output I get this:
2
11402
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 remove it 1) XSLT templates? 2) Copy all the contents into a new node and leave out the namespace? Use this node node in lieu of the old one?
11
4306
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
1530
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 it=map_.begin(); there will be memory violation. So, the iterator IS invalidated even if it's not the removed one. why? -----------
6
2056
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" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xmlns="http://www.w3.org/2000/xmlns/" xmlns:mathematica="http://www.wolfram.com/XML/" version="1.0">
3
7266
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, .Net likes to add these namespaces: <RootNode xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ChildNode xmlns="MyObjectHierarchyNamespace/> </RootNode> The problem this is causing me is that...
10
3589
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 not used in the result document or the stylesheet also I find that (for namespaces that are referenced in the stylesheet) even if I put an explicit namespace declaration on the root element of the result
0
8323
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
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
8613
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...
1
6176
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
5638
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
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1732
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.