Quantcast
Viewing all articles
Browse latest Browse all 3201

John Blackbourn on "Passing HTML, Inside XML as Post Content with wp_insert_post"

You should do a var_dump( $wpbb_params ) to see what exactly you've got. As you mention, $wpbb_params['Details'] is probably an array, not a string, due to the presence of its child elements.

Rather than running the result of simplexml_load_string() through json_decode( json_encode() ), I'd use it as the SimpleXMLElement object that it is.

$xml = simplexml_load_string( $wpbb_xml_content );
$content = (string) $xml->Details;

$content will then contain the string representation of your Details node. You can do a similar thing for your title:

$title = wp_strip_all_tags( (string) $xml->Title );

Take a look at the SimpleXMLElement page on php.net for more info.


Viewing all articles
Browse latest Browse all 3201

Trending Articles