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

XML validation with parseFromString on Safari

jul
Hi,

When I use parseFromString on Firefox or loadXML on Internet Explorer,
I can know if it's a valid xml content but when I use parseFromString
on Safari, I get a part of the content until it's invalid but I can't
know if the content is valid or not.

Someone has any idea ?

Thanks

Julien
Jun 27 '08 #1
1 2299
pr
jul wrote:
When I use parseFromString on Firefox or loadXML on Internet Explorer,
I can know if it's a valid xml content but when I use parseFromString
on Safari, I get a part of the content until it's invalid but I can't
know if the content is valid or not.

Someone has any idea ?
Unless I've missed something, Firefox's DOMParser doesn't validate XML
against a DTD or schema, so I'm thinking you mean 'well-formed' rather
than 'valid'.

In the case of both Firefox and Safari, you can determine whether a
string parsed successfully by the presence of a <parsererrorelement in
the resulting XML document. They differ about where you find it and what
namespace it is in, yet you can still do something simple like this:

var s, x, p = new DOMParser();
s = "<my-xml>" +
"<ok>content</ok>" +
"<rubbish>&</rubbish>" +
"</my-xml>";
// & is an error - remove it to make result OK

x = p.parseFromString(s, "text/xml");

alert(x.getElementsByTagName("parsererror").length ?
"xml error" : "ok!");
You could use x.evaluate() in place of x.getElementsByTagName().
Jun 27 '08 #2

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

Similar topics

23
by: Ash | last post by:
Hi everyone, This problem has been puzzling me for a fair time now, and has severely frustrated me!! Perhaps I'm just not getting the syntax right, but the problem is rather simple... Take a...
67
by: Scott Meyers | last post by:
I have a web site that, due to maintenance by several people, some of whom are fairly clueless about HTML and CSS, etc. (notably me), has gotten to the point where I'm pretty sure it's suffering...
6
by: Stephen | last post by:
Hi, Does Validation controls like "Required field validator".... ever work with Netscape or we have to write javascript for either client-side or write server side validation. Please advice....
4
by: David Colliver | last post by:
Hi all, I am having a slight problem that hopefully, someone can help me fix. I have a form on a page. Many items on the form have validation controls attached. Also on this form are...
4
by: metoikos | last post by:
I've scoured the web (clumsily, I'm sure) for information on the difficulties I am having, checked my markup in validators, and had a friend with more CSS clue look over it, but I haven't had any...
11
by: Rik | last post by:
Hello guys, now that I'm that I'm working on my first major 'open' forms (with uncontrolled users I mean, not a secure backend-interface), I'd like to add a lot of possibilities to check wether...
2
by: Jeff | last post by:
Okay, I read that Safari is now available for Windows, so I downloaded it to test on a vb.net/visual web developer 2005 app. that I created. The app works fine in other browsers. While in...
3
by: Ken Shimizu | last post by:
I get an error when submitting an .ASPX page in Safari beta, MAC and PC document.getElementbyId(‘FolderBrowser’).submit(); After the server side code has executed without problems I get the...
1
by: jamestpaul | last post by:
I'm having some difficulty with Safari users and hidden fields in my .NET 2 asp application. There is a hidden field that gets loaded with the contents of a div in my form. When the user submits...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.