c# updating my xml sheet automatically after connecting with a webpage - c#

This question is related to XML file. I have some content as shown below in a webpage:
Description App Name Information
Some Desc1 App1 Some Info
Some Desc2 App2 Some Info
Some Desc3 App2 Some Info
Some Desc4 App3 Some Info
Some Desc5 App4 Some Info
My question is Can I make my c# application to update my XML sheet automatically after connecting with this webpage? That is I want to pull some or all the data from a webpage each time I start my application. This is because manual updation of XML sheet each time is not possible.
Please note that I have not created any XML files for this so far.
Any comments would be really appreciated.

It's easy to get web page
you can do that by using
WebClient (How to get data from web page?)
or
by using
HttpWebRequest and HttpWebResponse
class,
but to get specific data from a web page please
follow this
(Getting a specific data from webpage using only class items)
Download and install the HtmlAgilityPack from nuget. Then using xpath pull specific information as you need.
then you can use that information to create xml elements as per you desire. I suggest you to use XElement or XDocument.

Related

How to get a drive ID from a SharePoint List (Document Library) for uploading files?

I want to be able to upload a text document to a SharePoint List. Since it is actually a Document Library, I believe I should upload files as though I am uploading to a Drive. I can upload a file to the site's root location. I can get the ID of the List I wish to upload to. However the Microsoft Graph API does not appear to like the ID I provide when I use that as the destination. ListItem says that ListItems are exposed as DriveItems when using a Document Library. How to upload a small file to SharePoint.
I have been testing with C# and GraphExplorer. It boils down to my endpoint being incorrect.
When using Graph Explorer, I can query for all drives with these two queries:
graph.microsoft.com/v1.0/sites/{siteid}/drives
The query displays the Drive Name I am looking for and the ID it shows is different than its list ID. This indicates to me that a Document Library has a separate List ID and Drive ID.
Status Code 201 (Created):
graph.microsoft.com/v1.0/sites/{siteid}/drive/items/root:/testplaceholder.txt:/content
Status Code 404 (Not Found): graph.microsoft.com/v1.0/sites/{siteid}/drive/items/{listid}:/testplaceholder.txt:/content
Status Code 400 (Bad Request): graph.microsoft.com/v1.0/sites/{siteid}/drive/items/{driveid}:/testplaceholder.txt:/content
Can anyone tell me where my understanding is lacking, or where I might have messed up? Sorry for the lack of code formatting, couldn't get it to work on the URL strings.
ANSWER:
Using the Drive ID I found with the first query above.
graph.microsoft.com/v1.0/sites/{siteid}/drives/{driveid}/root:/testplaceholder.txt:/content
Sample endpoint to upload file to a library.
https://graph.microsoft.com/v1.0/sites/siteid/drives/b!zEu8xWMaOU-BdU94l2XA7SAospdkDeREgpABeq2Ahp2VZN3js8mQTq_JU5kiCSsB/root:/test.txt:/content

Reading FIlemaker XML with C# WebRequest

I am trying to use FileMaker's XML WebPublishing feature. When I try to request a database from filemaker via Mozilla I get a user/pass request..when I enter that info the XML file loads. When I try this on IE, I get a blank result.
I then tried to use c#'s webrequest function to load the URI and I am getting a blank result when using the network credentials, when i omit the credentials I get a 401 unauthorized error (expected); I can't seem to figure out why I am getting a blank result.
I'm not sure if this will work, but have you tried inserting the credentials into the URL?
http://user#password:server.company.com/fmi/xml/fmresultset.xml?-db=...
There was a same question, how to get data from FileMaker database. I know 3 solutions:
1. FileMaker php Api. Use to create web service between database and your application
2. FileMaker XML Api. It's easier than first solution, and no need know php.
3. Now open sourced RESTfm project that uses XML and php api's and create a simple web service to fetch data in JSON format.
Hope it will help you.

How do I apply SharePoint web service to return ModifiedBy, TimeLastModified, UniqueID and FileType for a document?

I am currently successfully applying C# code via a SharePoint web service (http://company.name.com/_vti_bin/lists.asmx) in an SSIS Task (SQL Server 2008 RS) to check in and check out files in various folders on a SharePoint site (2010) using the input of URL values like that shown below. However, I now have a new task for a separate set of documents in SharePoint applying the same environment. I must also gather the name of the user who last modified each document, the time it was last modified, the SharePoint Unique ID, and file type. I am using the SharePoint web service because the database service is located on a different server than the SharePoint server.
For each document I have a unique URL path, such as:
http://company.name.com/a/abc/projects/Project_1.xls
http://company.name.com/b/def/projects/Project_4.xls
Can somebody provide a simple C# example of retrieving (not updating) the four attributes of interest using SharePoint webservices for a document posted on a SharePoint site given a URL value like one of those listed above? A console application example would be fine, since it is similar to a SSIS task script.
If it will assist, I've provided below the code for checking in and checking out files in a SSIS script task. Prior to setting up the code, I added a Web Reference called SharePointListsService applying the Web Reference URL "http://community.teamcomcast.com/_vti_bin/lists.asmx".
SharePointListsService.Lists listService = new SharePointListsService.Lists();
listService.Credentials = System.Net.CredentialCache.DefaultCredentials;
//Check out a file in SharePoint using the URL
string fileCheckout = "http://company.name.com/a/abc/projects/Project_1.xls";
bool myResults = listService.CheckOutFile(fileCheckout, "true", DateTime.Now.ToString("f"));
//Check in a file in SharePoint using the URL
string fileCheckin = "http://company.name.com/a/abc/projects/Project_1.xls"
myResults = listService.CheckInFile(fileCheckin, "Completed revision.", "0");
With the above code as an example, can somebody provide me with a similar code example using C# and SharePoint web services that returns the following attributes for a given URL for a file?
ModifiedBy
TimeLastModified
UniqueID
FileType
Thanks
I found a great workaround to the tedious code that would have otherwise been necessary. The following link provides a means to down load an adapter and documention for applying it. The adapter integrates SSIS and SharePoint. That is, it will allow you to add a SharePoint Source and SharePoint Destination task items under Tools that can be used to pull information from SharePoint almost the same as you would from a database or Excel file. I've set it up and it's working great.
http://sqlsrvintegrationsrv.codeplex.com/releases/view/17652
Using the adapter I can capture the attributes (Author, Modified By, Last Modified, and so forth) associated with one or more documents posted on SharePoint source and easily send the values to either a new SharePoint destination or Excel or database destination.

Use HTML string from Server Requets, and create the web page without saving it a file [in C#]

I´m sending the value of a variable via POST to a PHP page in C#. I get the data stream from the server that has all the web page in HTML with the value of the POST. This information is stored in a string variable.
I would like to open a browser and show the web page (maybe using System.Diagnostics.Process.Start("URL")), without having to save it in a file, this is showing the page in the moment and, when the browser is closed, no file is stored in the server.
Any idea?
Drop a WebBrowser control into a new form webBrowser1 and set its DocumentTextProperty to your result html
webBrowser1.DocumentText = ("<html><body>hello world</body></html>");
source:
<html><body>hello world</body></html>
You aren't going to be able to do that in an agnostic way.
If you simply wanted to open the URL in a browser, then using the Process class would work.
Unfortunately, in your case, you already have the content from creating the POST to the server, and you really want to stream that response in your application to the browser.
It's possible among the some browsers, but it's not able to be done in an agnostic way (and it's complicated even when targeting a specific browser).
To complicate matters, you want the browser to believe that the stream you are sending it is really coming from the server, when in reality, it's not.
I believe that your best bet would be to save the response to the file system in a temp file. However, before you do, add the <base> tag to the file with the URL that the file came from. This way, relative URLs will resolve correctly when rendered in the browser.
Then, just open the temporary file in the browser using the Process class.

Creating a Dynamic iCalendar Feed

I am looking for a means to generate a iCalendar feed using .Net , atm I am using the DDay library to generate the iCal file and write it to the response.
The problem with this is if I feed the URL to outlook it says that it is a invalid ics file.
I have tried various routes including :
Using MVC routing so that the link contains a .ics extension.
Changing the Mime Type so that it is Text/Calendar.
One observation I have found is that if I navigate to the URL in a browser a valid iCal file is generated and is imported into Outlook correctly. Secondly if I take that exactly file and host it via IIS as static content , Outlook picks it up as a valid file.
The problem is that I need to generate a Dynamic feed and seem to have run out of things to try and get this working.
It seems the problem in my case was that the default asp.net auth was blocking outlook because it was not authenticating , once a exception was added to the web.config , the URL loaded correctly in outlook

Categories