Hi Folks
I am trying to access an HTML code stored as CDATA section in the xml
file listed bellow:
<?xml version="1.0"?>
<results count="5">
<![CDATA[
<table><tr><td> Hello World</td></tr></table>
]]>
</results>
The xml tree is the responseXML part of an XmlHttpRequest and is stored
in a the javascript object xmldoc. While trying to test the node type
of the children of the "results"-Element I got different results with
IE and Mozilla:
xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[0].nodeType -->
MN=>TEXT,IE =>CDATA
xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[1].nodeType -->
MN=>CDATA,IE =>NULL
I added a non empty text node to the result element:
<results count="5">
blalba text
<![CDATA[...
Now I get this:
xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[0].nodeType -->
MN=>TEXT,IE =>TEXT
xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[1].nodeType -->
MN=>CDATA,IE =>CDATA
Does someone have an explanation for this behaviour?
I am using Mozilla 1.5 and IE 6
Cheers,
Aziz 7 4114
Aziz -
You need to keep in mind that Mozilla has a very rough time conforming to
standards. Especially when dealing with XML. You will need to run a "fixer
utility" on your XML data before Mozilla can understand it. Here is the
problem:
<parent>
<child1/>
<child2/>
<child3/>
</parent>
What you have there is a parent with 3 children to every XML parser in the
world but Mozilla's. In Mozilla you have a parent with 7 children. Mozilla
treats each line break as a child. In order to combat this you need to loop
through every child and if the nodeType = 3 and the nodeName = '#text' and
the number of childNodes > 1 then you know that what you have there is a
fake child and you can remove that node.
~Digital~
"Aziz" <ra*******@goog lemail.com> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.com... Hi Folks I am trying to access an HTML code stored as CDATA section in the xml file listed bellow:
<?xml version="1.0"?> <results count="5"> <![CDATA[ <table><tr><td> Hello World</td></tr></table> ]]> </results>
The xml tree is the responseXML part of an XmlHttpRequest and is stored in a the javascript object xmldoc. While trying to test the node type of the children of the "results"-Element I got different results with IE and Mozilla:
xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[0].nodeType --> MN=>TEXT,IE =>CDATA
xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[1].nodeType --> MN=>CDATA,IE =>NULL
I added a non empty text node to the result element: <results count="5"> blalba text <![CDATA[...
Now I get this: xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[0].nodeType --> MN=>TEXT,IE =>TEXT xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[1].nodeType --> MN=>CDATA,IE =>CDATA
Does someone have an explanation for this behaviour?
I am using Mozilla 1.5 and IE 6
Cheers, Aziz
To clarify it isn't the line break per se but any white space between tags
generates another child. e.e. <parent> <child>First Born</child>.... The
space between <parent> and <child> will give you that extra child node in
the XML parser.
"Digital" <re****@spam.co m> wrote in message
news:tv******** **********@torn ado.rdc-kc.rr.com... Aziz -
You need to keep in mind that Mozilla has a very rough time conforming to standards. Especially when dealing with XML. You will need to run a "fixer utility" on your XML data before Mozilla can understand it. Here is the problem:
<parent> <child1/> <child2/> <child3/> </parent>
What you have there is a parent with 3 children to every XML parser in the world but Mozilla's. In Mozilla you have a parent with 7 children. Mozilla treats each line break as a child. In order to combat this you need to loop through every child and if the nodeType = 3 and the nodeName = '#text' and the number of childNodes > 1 then you know that what you have there is a fake child and you can remove that node.
~Digital~
"Aziz" <ra*******@goog lemail.com> wrote in message news:11******** *************@g 44g2000cwa.goog legroups.com... Hi Folks I am trying to access an HTML code stored as CDATA section in the xml file listed bellow:
<?xml version="1.0"?> <results count="5"> <![CDATA[ <table><tr><td> Hello World</td></tr></table> ]]> </results>
The xml tree is the responseXML part of an XmlHttpRequest and is stored in a the javascript object xmldoc. While trying to test the node type of the children of the "results"-Element I got different results with IE and Mozilla:
xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[0].nodeType --> MN=>TEXT,IE =>CDATA
xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[1].nodeType --> MN=>CDATA,IE =>NULL
I added a non empty text node to the result element: <results count="5"> blalba text <![CDATA[...
Now I get this: xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[0].nodeType --> MN=>TEXT,IE =>TEXT xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[1].nodeType --> MN=>CDATA,IE =>CDATA
Does someone have an explanation for this behaviour?
I am using Mozilla 1.5 and IE 6
Cheers, Aziz
Digital wrote: You need to keep in mind that Mozilla has a very rough time conforming to standards. Especially when dealing with XML.
Are you trolling?
Here is the problem:
<parent> <child1/> <child2/> <child3/> </parent>
What you have there is a parent with 3 children to every XML parser in the world but Mozilla's. In Mozilla you have a parent with 7 children.
Does "every XML parser in the world" include the DOM implementation in
PHP 5?
Doing
$xmlMarkup = <<<EOD
<parent>
<child1/>
<child2/>
<child3/>
</parent>
EOD;
$xmlDocument = new DOMDocument();
if ($xmlDocument->loadXML($xmlMa rkup)) {
echo 'Number of child nodes: ' .
$xmlDocument->documentElemen t->childNodes->length;
}
else {
echo 'Parse error.';
}
there gives
Number of child nodes: 7
Does "every XML parser in the world" include the DOM implementation in
Opera 8? Doing
var xmlDocument = new DOMParser().par seFromString([
'<parent>',
' <child1/>',
' <child2/>',
' <child3/>',
'</parent>'
].join('\r\n'), 'application/xml');
alert(xmlDocume nt.documentElem ent.childNodes. length);
there alerts 7.
The same with Opera 9.
Does every XML parser in the world include the Java parser that guy
<http://groups.google.c om/group/comp.lang.java. programmer/msg/b2073fbf8a38066 9?hl=en&>
is using?
--
Martin Honnen http://JavaScript.FAQTs.com/
Thanks for the help. I have modified my PHP server side code to provide
the xml response as a string with no \n or \r. To clarify it isn't the line break per se but any white space between tags generates another child. e.e. <parent> <child>First Born</child>.... The space between <parent> and <child> will give you that extra child node in the XML parser.
"Digital" <re****@spam.co m> wrote in message news:tv******** **********@torn ado.rdc-kc.rr.com... Aziz -
You need to keep in mind that Mozilla has a very rough time conforming to standards. Especially when dealing with XML. You will need to run a "fixer utility" on your XML data before Mozilla can understand it. Here is the problem:
<parent> <child1/> <child2/> <child3/> </parent>
What you have there is a parent with 3 children to every XML parser in the world but Mozilla's. In Mozilla you have a parent with 7 children. Mozilla treats each line break as a child. In order to combat this you need to loop through every child and if the nodeType = 3 and the nodeName = '#text' and the number of childNodes > 1 then you know that what you have there is a fake child and you can remove that node.
~Digital~
"Aziz" <ra*******@goog lemail.com> wrote in message news:11******** *************@g 44g2000cwa.goog legroups.com... Hi Folks I am trying to access an HTML code stored as CDATA section in the xml file listed bellow:
<?xml version="1.0"?> <results count="5"> <![CDATA[ <table><tr><td> Hello World</td></tr></table> ]]> </results>
The xml tree is the responseXML part of an XmlHttpRequest and is stored in a the javascript object xmldoc. While trying to test the node type of the children of the "results"-Element I got different results with IE and Mozilla:
xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[0].nodeType --> MN=>TEXT,IE =>CDATA
xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[1].nodeType --> MN=>CDATA,IE =>NULL
I added a non empty text node to the result element: <results count="5"> blalba text <![CDATA[...
Now I get this: xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[0].nodeType --> MN=>TEXT,IE =>TEXT xmldoc.getEleme ntsByTagName("r esults")[0].childNodes[1].nodeType --> MN=>CDATA,IE =>CDATA
Does someone have an explanation for this behaviour?
I am using Mozilla 1.5 and IE 6
Cheers, Aziz
Hi all
After seeing all those problems with XML and Mozilla, I am just asking
myself , if Mozilla is
really that good Browser. In Order to be compatible with all Browsers,
I use now reponseText with AJAX to transport the http response and not
responseXML . I still can not imagine that Mozilla does not support
xmlResponse like IE.
Any idea?
Cheers
Aziz az**********@gm ail.com wrote: [...] After seeing all those problems with XML and Mozilla, I am just asking myself , if Mozilla is really that good Browser. [...]
You *are* trolling. FOAD.
PointedEars az**********@gm ail.com wrote: Hi all After seeing all those problems with XML and Mozilla, I am just asking myself , if Mozilla is really that good Browser.
Mozilla Foundation has nothing to do with the "unwanted nodes" problem.
They just strictly implement the relevant W3C standard.
By W3C an XML structure is being preserved in that exact state as it
came to you. By IE XML structure is being optimized by parser, which
means much lesser problems but the original XML changed.
There is a long lasting discussion about what is more
programmaticall y-wise correct at
<http://bugzilla.mozill a.org/show_bug.cgi?id =26179> where you are
welcome to join.
I'm not a participant of that discussion but I really like proposals to
make "exact nodes preservation" an option one would be able to turn on
and off.
The chances to have it ever blessed by W3C are very weak though, so all
kind of "TreeWalker s" still remain a must. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Piotr Wolski |
last post by:
how to make my page that it was correct with every browser standard?
for example when i change HTML's table size it has no effect when i see
it under mozilla and has effect under Internet explorer-does anyone know
how to solve that problem??
|
by: Dave Matthews |
last post by:
Hi folks,
I'm writing a web-page editing tool for my company which will allow
staff (with no "technical" expertise) to maintain their own Intranet sites.
The content for each webpage is stored in the form of XHTML in an XML
document (which, in turn, is stored in an XML database). So far so good.
However the editing tool must allow users to paste in the contents of MS
Word documents. I soon discovered that Word does not generate...
|
by: hsomob1999 |
last post by:
so i have a <ul> and I allow the user to append items to it. The
problem is that on mozilla the <span class="line"> which is just a line
to divide the sections
gets overlaped and doesnt move down and adjust to the newly added items
like it does in iE. It just occured to me that i dont really have to
use a span, and a html <hr> tag could do the trick -I will go try. But
aside from that could some one explain why this occurs? And will I get...
|
by: Simon Brooke |
last post by:
Here's my problem:
<xsl:template match="/category">
....
<script
type="text/javascript">
<!]>
</script>
....
</xsl:template>
|
by: bennett.matthew |
last post by:
Hello all,
This is probably an elementary (no pun intended) question, but I've
spent all afternoon on it and it's driving me crazy.
I have a function which dynamically adds to a table. It receives a
variable which basically encapsulates this:
<div id="tableid">
<tr>
| |
by: Moses |
last post by:
HI
The Value for childNodes.length differs with mozilla and IE
Is it problem with my coding..... I could not under
stood.............
The following is the details
|
by: Pugi! |
last post by:
Using AJAX I want to send some information from the server (php-page)
as XML to the client. The contents can be very divers so I have to use
XML instead of text. On one occasion the contents is html, I can put
this in a CDATA section with PHP, but how do I retrieve that
information with Javascript and put the HTML in a div ?
thanx,
Pugi!
|
by: Max |
last post by:
Hello everyone!
Can anyone help me to convert the CDATA expression "CDATA ::= (Char* -
(Char* ']]>' Char*)" to Javascript Regular Expression?
Thanks,
Max
|
by: Dariusz Tomoñ |
last post by:
Hi,
I have got xml document with CDATA sections containing special characters
like links to images. All Iwant is to display the content in my div
section.
I tried like this:
protected void Button2_Click(object sender, EventArgs e)
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |