John
John

Reputation: 1913

Undefined error when trying to load XML

I have a big 400kb xml file.

When i try to load it by using:

I get Undefined error in both methods. I took the file and pasted to xml validation webpage, it valides ok...

What else can i do?

By the way, Is there any max length for the attribute in the element?

EDIT

it seems that it cannot load long attribute ... i have part of another xml in the xml's attribute value ...

An error pops up: Undefined error. Line: 1 (here is the begining of the xml)
Class of the exception is: EDOMParseError

Generally i would like to achive something like this:

<doc type="X223">
  <params id_param="51" value="XML_1" />
  <params id_param="52" value="XML_2" />
  <params id_param="53" value="XML_3" />
</doc>

Upvotes: 1

Views: 871

Answers (1)

TLama
TLama

Reputation: 76693

If you can change your schema, prefer to store your inner XML files to CDATA section, if not then try to think about following.

Parser failed on your element attribute value most probably due to quote character contained in an XML file you've tried to store there. Consider the following case for instance:

<params id_param="51" value="<innerxmlattributevalue="value">"/>

As you can see, you might confuse parser with the quote char from that inner XML, so that it could take the above line as:

<params id_param="51" value="<innerxmlattributevalue="
value">"/>     <-- here is expected to be another attribute or closing bracket

The easiest you can do when you want to keep your current schema is to escape all quoting characters of your inner XML file.

From the RFC 2629 specification (emphased by me):

Make sure that all attributes values are quoted, e.g., "<example name='value'>", If the value contains one of the quoting characters, then use the other to quote the value, e.g., "<example name='"'>", If the value contains both quoting characters, then use one of them to quote the value, and replace occurrances of that character in the attribute value with either '&apos;' (apostrophe) or "&quot;" (quotation), e.g., "<example name='"&apos;"'>".

Upvotes: 2

Related Questions