adding newline to xml file while creating using libxml1.2.3 - libxml2

How can one add new line using libxml1.2.3. in xml file.

When you dump xml output use xmlSaveFormatFileEnc instead of xmlSaveFileEnc. In general use format family of functions, like they do in tree2.c example.

Related

How to convert a .txt file to a .url file in R?

I create a text file below:
myFile<-file("toGoogle.txt")
writeLines(c("InternetShortcut]","URL=http://www.google.com","IconFile=http://www.google.com/favicon.ico",
"IconIndex=0"), myFile)
close(myFile)
For clarity the text file now contains the following:
[InternetShortcut]
URL=http://www.google.com
IconFile=http://www.google.com/favicon.ico
IconIndex=0
In Windows, if I manually rename the file to "toGoogle.url" I am prompted:
After saying "Yes" the file is now a usable web link:
However when I use file.rename or any other substitute in R to change the file extension of toGoogle.txt it creates a dead web link with a target of "".
Is there a simple way out there to create a web shortcut using R? Or how can I change the file extension in R in a way that Windows is going to recognize it?
Edit: Using R to make the url weblink gives this:
And opening it prompts me with this:
The function file.rename works for me. And why not use file("toGoogle.url") to create a .url file directly.

Save text files with a different extension in r

I'm trying to write out an R output to a text file that is not saved as .txt but as some other unique identifier (for example .prt). I know that's possible with matlab, but I don't know how to get that to work with R.
I can't find any package to do that, and when I try to specify the extension in the file name it give me an error and doesn't save.
Any idea would be greatly welcome! Thank you.
Unless you are using some specialized package, a lot of standard R functions for writing data to files have a file= parameter (or similar) to let you specify whatever the filename (and extension) you want. For example:
dummy.data <- matrix(rnorm(25),ncol=5)
### in reality you could just write file="dummyfile.prt" as one string
### but for demonstration purposes, you can use paste0() or paste(,sep='')
### to create a new file name using some variable prefix and your extension
### ".prt"
### sep='\t' makes the output tab-delimited
write.table(dummy.data,file=paste0("dummyfile",".prt"),sep='\t')

xdmp:document-load Xquery Command

When I ingest a csv file containing multiple xml records using mlcp, I use an options file to change the desired ML output from one csv document into multiple xml documents. How do I script this using xdmp:document-load command within the query console?
I don't think xdmp:document-load provides an option for that. Instead, use xdmp:document-get, split with XPath, then xdmp:document-insert.

R: Possible to include some "header" files?

I'm new to R and have a basic question. I want to save in a file some variables etc. which I use in several programs. Instead of pasting all the code in each program I want to include always the same file in each program. So if I change something in the Header file, the change takes place in all programs which use this header. How can I do something like this in R?
In my header I only want to define some variables used in all programs.
Just make a R source file, e.g. my_header.R and use the function source to include all variables defined in this file in all your scripts. You can just include the file with source('my_header.R'). Does this help?

How to generate Rich Text Format (RTF) document in ASP.NET?

How to generate Rich Text Format (RTF) document in ASP.NET?
The RTF specification from Microsoft:
http://msdn.microsoft.com/en-us/library/aa140277%28office.10%29.aspx
Or, in order to bypass the RTF learning curve, you could generate HTML from ASP.NET then shell out and use the html2rtf tool to convert it to rtf:
http://www.gkrueger.com/personal/html2rtf/index.html
Or, if your doc is going to be used in template-like manner, you could create the rtf file by hand in WordPad and save it with special strings that you invent, like $YOUR_NAME_HERE$. Later, you read the your saved rtf file and replace your special strings.
Just follow the spec:
http://en.wikipedia.org/wiki/Rich_Text_Format
Start your file with
MyFile.WriteLine("{\\rtf1 ")
and just follow the spec linked by Spencer.

Resources