PDA

View Full Version : how do I use " inside a node attribute


Dennis_gull
02-07-2008, 02:22 PM
Im not sure this is the right section but I didnt find any xml related section.
Got some problems with " and <, > in xml, It didnt work to just write \" or \< like in php, so is there a way to solve this or do I have to remove them? At the moment I use str_replace to delete them all but I rather make it work.

the binary
02-07-2008, 02:43 PM
put your text into <[CDATA[ your text here ]]> ..

Dennis_gull
02-07-2008, 03:13 PM
put your text into <[CDATA[ your text here ]]> ..

Thanks for the reply but I cant get it to work :confused:


<myXML>
<a t="<[CDATA[ this is "some" text]]>" />
</myXML>


It will return an error.

the binary
02-08-2008, 03:25 PM
it has to look like this..

<myXML>
<a><[CDATA[ this is "some" text]]></a>
</myXML>


//b

Dennis_gull
02-08-2008, 05:40 PM
it has to look like this..

<myXML>
<a><[CDATA[ this is "some" text]]></a>
</myXML>


//b

But thats not really an option :P
I got to use the nodes attributes to load the data.

its like this:
<main_node_gallery name="example 1" txt="some text here...">
<picture n="picture name" url="pic.jpg" txt="this is a picture" />
</main_node_gallery>

Dennis_gull
02-10-2008, 01:07 PM
I made a little function that replaced the ",< and >.
function r($v) {
$value = str_replace("\"","&quot;",$v);
$value = str_replace("<","&lt;",$value);
return str_replace(">","&gt;",$value);
}


r(<my info>) // call the function