Jump to content

[SOLVED] XML Special Characters


ssj16

Recommended Posts

Hi Guys,

 

I've been looking all over to try and figure this out but I am new to dealing with XML in PHP.

 

I have successfully read my XML file and echoed my data into a browser by returning a String using this function:

 

function getTitle($filePath){

$xmlDoc = new DOMDocument();

$xmlDoc->load($filePath . "\structure.xml" );

$searchNode = $xmlDoc->getElementsByTagName( "course" );

 

foreach( $searchNode as $searchNode )

{

$valueID = $searchNode->getAttribute('title');

        return $valueID;

}

 

 

}

 

But say if the value of my attribute had special characters in it such as:

 

<structure>

<course title="LOREM® IPSUM™">

        </course>

</structure>

 

The output in the browser would be: LOREM® IPSUM™

 

If i am missing something or parsing the data wrong any help would be of assistance.

 

Thanks  Alot

Link to comment
Share on other sites

THANKS ALOT GIZMOLA  :)

 

I thought about this but I thought it needed to be done on the XML side, since our XML pages do not have the encoding at the top, but now that I think about it, it definitely makes more sense that it would be in the PHP page since it's being processed.  Unfortunately, I never put the encoding at the top (laziness), but now I truly realize the importance of the encoding at the top of my html/php pages.

 

Once again, thank you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.