How to Create Self Terminating XML File using libxml2 - libxml2

I'm trying to create self terminating XML File using libxml2 , but as far as i have searched i got xmlSaveNoEmptyTags only, but i'm not sure how to use it. I'm using Objective C and libxml2 in Mac OS.

Try to analyze basic libxml examples. Does this one help: io2.c ? If not, edit the question and show the exact xml contents you would like to obtain.

Related

Saving an R-Script results in empty file

I have recently started using R for uni. I want to save my code using either save as or ctrl+s. However, the saved file is empty more often than not. For some reason, the files save normally on a few occasions. However, they also became empty after saving changes to the script.
I couldn't find any solution for the problem, neither here nor anywhere else.
I am using RStudio installed via Anaconda on an Windows 10 x64 Notebook, if that helps.
Thanks a lot for the responses! I'd be glad to provide more details if needed!
This is what the saved files look like from File Explorer:
I just meet the exactly same problem. I solved it by checking and changing RStudio -> File -> "Save as Encoding" from "ISO-8859-1 (System default)" to "UTF-8", then the file was saved. I'm trying to recover my previous 0kb files...
i couldn't reproduce the error but i also don't like to use the anaconda environment.
if the problem is saving the text file than may i suggest to do just that and save the code in a regular .txt file?
if this is not an option you can try to find out what happens if you save the r studio code on a different drive (or usb/flash drive)
###########################################################
EDIT 14.07.2022
Interestingly enough, just today (14.07.2022) I had the same problem. After installing R 4.2.1 everything worked fine until I changed the encoding (from utf-8 to windows 1252), at which point all the files in my project were overwritten and are now empty. Changing back to an older version of R (4.1.3) allowed me to display/save/use all scripts again (from backups).
Using the answer provided by #Shidan it is possible to open the data in R-4.2.1 as well.
This problem does not seem to be connected to Anaconda but an encoding issue between Rstudio and any R distribution above (and including) 4.2.

Accessing target of a windows shorcut

In linux machines, it is possible to access where a symbolic link is pointing to by using Sys.readlink function in R or readlink from the command line. Reading its documentation, we see that this is not intended for Windows shortcuts.
In Windows I have not been able to find a one liner to give me where the file points to. The closest I got was from this SO question that demonstrates the use of dir. While the output was not perfect I figured with some regex magic I could isolate the file path.
However when I tried system2('dir'), I received the error "dir" not found.
Is there (a better) way for me to access the file path of a Windows shortcut from R and why can't I use dir through a system call in R?
For anyone in the future finding this thread, the answer is fs::link_path() as pointed out by Edward Visel

Phabricator SVN Revision file context

I cannot get phabricator to display the changes in using the file context. I got the "Context not available" on every file.
Does anyone know why is this not work? What should i do to debug this problem?
This seems a problem related with SVN only because its working with GIT.
Thanks.
I bumped in the same problem recently and googled this question. I found out that the context is available only when diff is created via arcanist command line tool (arc diff) in Linux or Mac OS.
It won't work if you create a diff directly by pasting it in Phabricator/Differential or by using arcanist tool in Windows.
I tested this with arcanist on Ubuntu 14.04, Mac OS 10.10 (those two worked) and in Windows 7 (didn't work).
You didn't specify whether you're using the arc diff command line tool, or manually uploading a diff via the Phab. web interface.
If you're not using arc diff, I have an answer for you: It's up to you to include the context yourself. Phab. only knows what's in the diff/patch that you give it. If you can't get the full context, that's a fault with your diff/patch, not with Phab.
If you're using a standard diff utility, like GNU diff, you can use the command-line arguments to dictate how much context to include in the output. I usually use some obscenely large number, like 500 or 1000, to ensure that the entire file ends up in the output.
I just took a quick look at the svn command-line documentation, and it seems that there's no way to control how much context goes into the output. ...but maybe I'm wrong...
In any case, shortboy is correct that the easiest way to get the full file context is to use arc diff.

Google Prediction using R

Has anyone successfully used the Google Predication API from within R? My goal is to perform the following tasks:
Upload and manage the data in Google Storage
Use this data to train a model from Google Prediction
I have followed the install instructions located here and here (when using Windows). I have not been able to successfully connect using both Mac OSX and Windows.
I suspect that the core issue is authentication. There is scattered documentation and I feel like I have tried everything (even the overview of the R package designed for this purpose).
I am not the greatest programmer, but I can typically follow along with code and piece together what I need from worked examples. At this point, though, I simply do not know what else to try.
Many thanks in advance.
Marc Cohen seems to be right, I think something is broken. However I managed to pass authentication, here is how:
Download the googlepredictionapi_0.12.tar.gz and extract it inside a temporary folder. Then open googlepredictionapi/R/prediction_api_init.R inside an Editor and remove the lines
myEmail <- ""
myPassword <- ""
myAPIkey <- ""
Afterwards repackage the source files and load them in R:
tar czf googlepredictionapi.mod.tar.gz googlepredictionapi
R
remove.packages("googlepredictionapi")
Now you should be able to follow the steps in [1] http://code.google.com/p/r-google-prediction-api-v12/. However instead of calling
install.packages("googlepredictionapi_0.12.tar.gz", repos=NULL, type="source")
you need to call
install.packages("googlepredictionapi.mod.tar.gz", repos=NULL, type="source")
Following the steps, at some point a file $HOME/.auth-token should be generated.
(You can even explicitly trigger this by calling explicitely: PredictionApiUtilGetAuth(verbose=TRUE), myEmail and myPassword must be set beforehands.)
For some reason the global variables that are manually set in [1] have been shadowed by the removed lines above. The same is actually true for the verbose option which you can pass to most API function calls as extra option ..., verbose=TRUE).
Hope this helps.
Last I heard (April of this year), R support for the Google Prediction API was not yet upgraded to use OAuth so when the Prediction API switched from the older client login scheme to OAauth 2.0, it effectively broke R functionality.

How do you change library location in R? [duplicate]

This question already has answers here:
Painless way to install a new version of R?
(12 answers)
Closed 6 years ago.
Due to the new R 2.11 release, I want to implement Dirk's suggestion here.
So for that I am asking - How can I (permanently) change R's library path? (The best solution would be one that can be run from within R)
You can edit Rprofile in the base library (in 'C:/Program Files/R.Files/library/base/R' by default) to include code to be run on startup. Append
######## User code ########
.libPaths('C:/my/dir')
to Rprofile using any text editor (like Notepad) to cause R to add 'C:/my/dir' to the list of libraries it knows about.
(Notepad can't save to Program Files, so save your edited Rprofile somewhere else and then copy it in using Windows Explorer.)
I've used this successfully inside R script:
library("reshape2",lib.loc="/path/to/R-packages/")
useful if for whatever reason libraries are in more than one place.
This post is just to mention an additional option. In case you need to set custom R libs in your Linux shell script you may easily do so by
export R_LIBS="~/R/lib"
See R admin guide on complete list of options.
I'm late to the party but I encountered the same thing when I tried to get fancy and move my library and then had files being saved to a folder that was outdated:
.libloc <<- "C:/Program Files/rest_of_your_Library_FileName"
One other point to mention is that for Windows Computers, if you copy the address from Windows Explorer, you have to manually change the '\' to a '/' for the directory to be recognized.

Resources