8768

xml parsing with simple xml [duplicate]

Question:

<blockquote>

<strong>Possible Duplicate:</strong><br /><a href="https://stackoverflow.com/questions/1426852/problem-with-simplexml-and-entity-not-being-defined" rel="nofollow">Problem with simpleXML and entity not being defined</a>

</blockquote>

I have this tag with an entity in an xml file:

<comune>Forli&#39;</comune>

Simple xml in php fail to parse the file:

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: parser error : Entity 'igrave' not defined

How can i do?

Answer1:

I tried this a small example and it worked for me

XML:

<?xml version="1.0" encoding="UTF-8"?> <comune> <comune>Forli&#39;</comune> </comune>

PHP:

$xml = simplexml_load_file('test.xml'); foreach($xml->children() as $child){ echo '<pre>'; print_r((string)$child); echo '</pre>asd'; }

OUTPUT:

Forli'

Answer2:

Check this <a href="https://stackoverflow.com/questions/1426852/problem-with-simplexml-and-entity-not-being-defined" rel="nofollow">solution</a> for help

Recommend

  • Putting into table from a complicated array using php
  • Get an xml object by attribute
  • Parse RDF XML file to get all rdf:about values
  • Searching an XML file using PHP [closed]
  • What does the “?” mean in the following statement
  • How to override jQuery promise callback
  • Regex for nested values
  • In Java, how can I construct a File from a resource?
  • Is it possible to run clang with llc flags
  • VBA Excel, loop through variables
  • converter json to two dimensional array
  • Primefaces ManyCheckbox inside ui:repeat calls setter method only for last loop
  • Adding elements to a huge XML file
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • Unable to install Git-core+svn by MacPorts
  • C: Incompatible pointer type initializing
  • Django simple Captcha “No module named fields” error
  • How integrated is Collada to OpenGL ES
  • Jackson Parser: ignore deserializing for type mismatch
  • Could not find rake using whenever rails
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Master page gives error
  • Upload files with Ajax and Jquery
  • Do I've to free mysql result after storing it?
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Rearranging Cells in UITableView Bug & Saving Changes
  • How to pass list parameters for each object using Spring MVC?
  • Circular dependency while pushing http interceptor
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Is there a mandatory requirement to switch app.yaml?
  • Linker errors when using intrinsic function via function pointer
  • A cron job substitute?
  • json Serialization in asp
  • Hits per day in Google Big Query
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Linking SubReports Without LinkChild/LinkMaster
  • Can't mass-assign protected attributes when import data from csv file
  • sending mail using smtp is too slow
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass