& og xml

Kategori overført fra Linux1

& og xml

Innleggav Oztiz » man 23.04.2007 20:51

Hei!

Jeg har ett lite problem. I noen strenger som jeg ekporterer til xml filer inneholder tegnet &. Dette gjør at xml filen ikke blir riktig.
Noen som vet hvordan jeg skal behandle dette tegnet?
Eksempel: <firma>Hansen & Dysvik</firma>

Firefox sier:
XML-lesefeil: ikke velformet
Plassering: ################
Linjenummer 13, kolonne 18:
<firma>Hansen & Dysvik</firma>
-----------------^
medlem i 232 måneder
 

Innleggav geirendre » man 23.04.2007 21:02

Tipper du må "escape" den siden den er et spesialtegn.

Står noe om det her.

2.4 Character Data and Markup

Text consists of intermingled character data and markup. [Definition: Markup takes the form of start-tags, end-tags, empty-element tags, entity references, character references, comments, CDATA section delimiters, document type declarations, processing instructions, XML declarations, text declarations, and any white space that is at the top level of the document entity (that is, outside the document element and not inside any other markup).]

[Definition: All text that is not markup constitutes the character data of the document.]

The ampersand character (&) and the left angle bracket (<) may appear in their literal form only when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings "&amp;" and "&lt;" respectively. The right angle bracket (>) may be represented using the string "&gt;", and must, for compatibility, be escaped using "&gt;" or a character reference when it appears in the string "]]>" in content, when that string is not marking the end of a CDATA section.

In the content of elements, character data is any string of characters which does not contain the start-delimiter of any markup. In a CDATA section, character data is any string of characters not including the CDATA-section-close delimiter, "]]>".

To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character (') may be represented as "&apos;", and the double-quote character (") as "&quot;".

Erfaren
Brukerens avatar
medlem i 230 måneder
 

Innleggav Oztiz » man 23.04.2007 21:10

Tusen takk!
Akkurat det jeg så etter.
medlem i 232 måneder
 


Returner til Utvikling i Linux



Hvem er i Forumene

Registrerte brukere: Google [Bot]