Below you will find pages that utilize the taxonomy term “xml”
Posts
Count lines of code with PowerShell
Today I got a question:
How many lines of code are there in our SharePoint solution?
After a little search, I found that PowerShell is really a nice tool to count lines of code:
How do you count lines of code (stackoverflow)? I wanted to count lines for different types of code:
Code Behind written in C#, the files have .cs file extension JavaScript code (except jQuery, angular or knockout frameworks) PowerShell files (.
Posts
javascript: serialize as xml
Why should we need to serialize javascript objects as XML. I don’t know. It is of course more a server side need. And there actually a need for javascript serialization as xml in node.js. To serialize as json is very simple: JSON.stringify(myobjects). I was just curious if there was a tool for xml serialization in javascript. There is a nice javascript tool called XMLWriter, developed by Ariel Flesler. Consider you have articles and want to serialize them as xml, let’s create a function for serializing:
Posts
XMLHttpRequest the hard way
$.ajax is great, it hides much of the complexity. But sometimes we need to work with “raw” javascript :) So let’s look behind the scenes. The XMLHttpRequest (or just XHR) is used to open a connection to a server without a page reload. Internet Explorer calls it ActiveXObject and it differs in IE versions. Wikipedia article gives a good example how to create one constructor for all browsers: [sourcecode language=“javascript”]if (typeof XMLHttpRequest == “undefined”) XMLHttpRequest = function () { try { return new ActiveXObject(“Msxml2.
Posts
Ändra content i ContentEditorWebPart
Det finns ett exempel här.
//defaultAspx är sidan (SPListItem i Sidor) //måste checkas ut först //mgr är WebPartManager //wp är contentEditorWebPart web.AllowUnsafeUpdates = true; XmlDocument xmlDoc = new XmlDocument(); XmlElement xmlElement = xmlDoc.CreateElement("Content"); xmlElement.InnerText = ((Microsoft.SharePoint.WebPartPages.ContentEditorWebPart)wp).Content.InnerText.ToString(); xmlElement.InnerText = xmlElement.InnerText.ToString().Replace("#HEADING#", "Welcome for welcome"); wp.Content = xmlElement; mgr.SaveChanges(wp); defaultAspx.File.CheckIn(""); defaultAspx.File.Publish(""); web.AllowUnsafeUpdates = false; ```Man måste skapa nytt XmlDocument och XmlElement, om man försöker skriva direkt till wp.Content.InnerText kommer det inte uppdateras. I det här fallet, byter vi ut #HEADING# mot något mer passande.
Posts
Formatera export xml av wordpress
Ville spara min blogg som en dagbok för utskrift. Exporterade hela bloggen som xml. Inga problem. Sedan var det dock nästan omöjligt att enkelt skriva in det i Word / OpenOffice. Jag har skrivit en liten css-fil som formaterar det lite så att man kan skriva ut. Lägg till:
<?xml-stylesheet type = "text/css" href="wordpress.css"?> direkt efter:
<?xml version="1.0" encoding="UTF-8" ?> Lägg filen “wordpress.com” i samma mapp. Här är wordpress.css
channel title { font-size:3em; } channel description { color:green; margin-bottom:1em; } item title { font-size:2em; font-family:Arial; margin-top:1em; } creator { color:green; } creator:before { content:"Skrivet av: "; color:black; font-style:italic; font-size:0.