So while I was working on one of my outreach projects as a graduate student, I wanted to write a simple XML indenter to make my GWT generated xml more aesthetically appealing using stock GWT. The xml document is assumed to be as lean as possible (There are no empty #text nodes that are usually in xml because of the indentation.)
I should also mention that I’m posting this because I didn’t really see any stock simple GWT indenters after a quick google. The following is not meant to be a complete indenter, just something quick and simple to organize xml.
Here’s a basic indenter.
public String formatXML(Node node,String tab_str)
{
String formatted="";
if (node.getNodeType()==Node.ELEMENT_NODE)
{
String attributes="";
for (int k=0;k < node.getAttributes().getLength();k++)
attributes+=" "+node.getAttributes().item(k).getNodeName()+"=\""+node.getAttributes().item(k).getNodeValue()+"\"";
formatted=tab_str+"<"+node.getNodeName()+attributes+">\n";
for (int i=0;i< node.getChildNodes().getLength();i++)
{
formatted=formatted+formatXML(node.getChildNodes().item(i),tab_str+" ");
}
formatted=formatted+tab_str+"</"+node.getNodeName()+">\n";
}
else
{
if (node.toString().trim().length()>0)
formatted=tab_str+node.toString()+"\n";
}
return formatted;
} |
This is a greasemonkey script for firefox (not sure if it works with other browsers since it uses GM_openinTab). Simply put it can generate RSS feeds for old xanga entries, should you want to download them for archiving purposes for a diary perhaps, or should you want to migrate to another blogging framework. It took me around 2 hours in the wee hours of 4-6am in the morning to write.
I was trying to figure out why people were so into wordpress. It is pretty neat! Using WordPress’s rss import feature, I have demonstrated that I can import my old xanga entries for free and painlessly.
Install Greasemonkey script: Xanga2rss
Features:
- Handles Titles
- Handles Dates
- Handles Post content fairly well.
Instructions:
- Get Firefox, Greasemonkey Firefox-Addon (If you don’t have them both).
- Install using the above link.
- Visit a xanga blog, and look for the “Generate XML” link on the bottom of the page near the prev,next navigation links. This will open a new tab with the RSS 2.0 feed which an assortment of blogs (including wordpress) can read and import.
- For ease, I suggest you grab repagination, or antipagination depending on which firefox you have. Then right-click the “next” link, and goto repaginate, where you can combine shotgun amounts of pages into the current page. Go back to the first (actually never tried the other “Generate XML” links) “Generate XML” links and the resulting tab will hold all the posts.
TODO:
- I would like to very much figure out whether or not it would be possible to import comments via rss.
Categories: Education, Fun, Releases Tags: Fun, gm_openintab, greasemonkey, migration, pagination, rss, utility, wordpress, xanga, xml