Jump to content

Parsing Error and XML

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
dirkfirst

dirkfirst

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 354 posts
I get this error when parsing XML in PHP using the '&'

Xml parsing error: not well-formed (invalid token) (error code 4)

Is there a way to parse this character or remove it? It looks like the only option is to remove it.

#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
I don't know anything about parsing XML nor XML for that matter, but to replace characters in strings you could use str_replace() to replace "&" with a " ". You could also use preg_replace() but that uses regular expressions which give me a headache.

You may also want to read this Extensible Markup Language (XML) 1.0 (Fourth Edition)

Quote

Definition: Entity and character references may both be used to escape the left angle bracket, ampersand, and other delimiters. A set of general entities (amp, lt, gt, apos, quot) is specified for this purpose. Numeric character references may also be used; they are expanded immediately when recognized and MUST be treated as character data, so the numeric character references "<" and "&" may be used to escape < and & when they occur in character data.