Not able to display XML in Wordpress post

wordpress text editor code
wordpress code examples

If you want to display an XML fragment in a WordPress post - how do you do that?

Suppose you want to display this:

<family>
    <dad>whatever</dad>
    <mom>whatever</mom>
</family>

Using the [sourcecode language="xml"] does not help, as it mangles up the XML. Also, I believe, plugins cannot be used with free version of WordPress ( i.e wordpress.com ) - so, probably that won't be an option.

Using HTML <pre> tag works, but it does not give correct look and feel. Can any one show me how they have done it?


The wordpress codex has a whole page about writing code in your posts.

http://codex.wordpress.org/Writing_Code_in_Your_Posts

Their suggestion is to use html entity codes within <pre> or <code> tags

&lt;family&gt;
    &lt;dad&gt;whatever&lt;/dad&gt;
    &lt;mom&gt;whatever&lt;/mom&gt;
&lt;/family&gt;

This could be tedious if you have a lot of code to show in your post. I suggest writing a small shortcode that would do this for you.

<?php
function xml_shortcode( $atts, $content ) {
    return '<pre>' . htmlentities( $content ) . '</pre>';
}

add_shortcode( 'xml', `xml_shortcode` );
?>

How to use your shortcode in a post

[xml]your code here[/xml]

xml file not importing, Support » Plugin: One Click Demo Import » xml file not importing You should have a log file in the *wp-admin -> Media* section. Did you try to enable I am trying to import manualy, no error display. All custom post types failed to import (that's normal, because I didn't register these custom post types). Hi, After 2 days researching how to display these feeds in wordpress, I found nothing! :-( Can someone please explain to me how to display these feeds


If [sourcecode] is available but you cannot install additional plugins or add shortcodes (which is the case on wordpress.com), you have, to my knowledge, no other option than to encode the problematic characters before copying them.

Here are the detailed steps:

  1. Encode your snippet using an HTML encode, for instance using a free, online encoder
  2. edit your post in HTML mode
  3. add [sourcecode language="xml"]
  4. past the encoded source code
  5. add [/sourcecode]

What Is XML and How Can You Use It With WordPress?, In this post, we'll answer those questions, and offer a primer on XML's basics! Then we'll explore a few of the ways you can use XML in WordPress. won't be able to understand the results and display them properly. I'm trying to work with an API that expects an XML string in the body of the post. Additionally, the docs for the API specify: Please post with mime-type text/xml with the XML in the body of the post . I want to use the WordPress HTTP API to make this work, but I'm running into some problems.


I suffered from this problem recently. For me what worked was to enter the code in text mode. Selection of code. Application of code formatting from the Format menu.

Later, I used the crayon syntax highlight plugin. The plugin works well, you have to follow the same process as above with the only difference that instead of code formatting option, choose the crayon option after selecting the code to highlight.

You can check the highlighting here

WordPress Import Failed? Here's How to Fix It, Export XML data. You probably already did this. If not, go to your old WordPress website. In the WP-Admin area, find the Tools > Export menu  WP All Import – Simple & Powerful XML / CSV Importer Plugin “It’s a wonderful plugin that does so much, so well that it’s hard to list all of the features. But I’ll tell you this, I was able to import the content of a pair of websites running the ModX CMS into a WordPress install in less than 30 minutes. No joke!”


Wordpress.com now has built-in support for code highlighting in a variety of languages using the [code] shortcode. I find that I still have to use html entity codes when highlighting XML, but other languages work well (JavaScript, C#, etc.), and it looks much better to the reader than your basic <pre> or <code> tags.

Plugin or advice on how to parse XML in real-time?, What I would like to do is to display this content in a post during the games so that media members could have access to it. I'd like to be able to  If you want to display an XML fragment in a WordPress post - how do you do that? Suppose you want to display this: <family> <dad>whatever</dad> <mom>whatever</mom> </family> Using the [sourcecode language="xml"] does not help, as it mangles up the XML.


Custom post type's posts are not showing anywere but in xml sitemap, There are several tutorials like this one from WPBeginner that tell you how to create, then display a custom post type. You may need to create  I have a problem, I need to display an XML file that is hosted on a remote server. That file I want to display it with CSS and PHP in a file that is already assigned (page-xxxx.php) I am currently using the following code, however I do not understand very well what I do:


50 Most Common WordPress Errors and How to Fix Them, In case you are unable to resolve your issue from the steps mentioned in this How to Fix WordPress Posts Returning 404 Error A user may be unable to find out how to align images, resize or crop them, or display them in a gallery format. XML Parsing Error: XML or text declaration not at start of entity How do I display all wordpress-posts in a custom xml-sheet? Ask Question Asked 8 years, 1 month ago. Wordpress Custom Page, posts not displaying. 0.


Topic: Failed to import XML sample data., en WordPress.com Forums › Support Failed to import XML sample data. Tools>​Import>Wordpress Failed to import post tag Failed to import post tag Failed Failed to import “The next-gen MacBook Pro with Retina Display  This plugin adds the ability to import content from an external XML/RSS file, or from an uploaded XML/RSS and add the content to any post type in your WordPress install. It also supports importing taxonomies alongside posts. The process of import: Select the source ( URL or FILE UPLOAD )