About SharePointSwagger

SharePoint Developer

Azure Active Directory Graph API

Demonstrates use of the AAD Grpah API to perform common read and write operations on Users, Groups, Group Membership, Roles, Tenant information, Service Principals, and Applications.


To  make connection to your own azure active directory using the Graph API,You need to make the application and get client id and recreate key from the azure portal

Register the sample app for your own tenant

1. Sign in to the Azure management portal.
2. Click on Active Directory in the left hand nav.
3. Click the directory tenant where you wish to register the sample application
4. Click the APP Registrations tab
5. In the drawer, click New Application Registration
6. Enter friendly name to the application name
7. Select application type Web Api Or native from the given dropdown.
8.For the Sign-on URL, enter a value (NOTE: this is not used for the console app, so is only needed for     this initial configuration): “http://localhost
9.Click on Create button
10.Copy the application id from the portal and paste it in a side. we will need it in later stage as client    ID.
11.Click on settings
12.Click on Keys
13.Under the Keys section, select either a 1-year or 2-year key – the keyValue will be displayed after you save the configuration at the end – it will be displayed, and you should save this to a secure location. NOTE: The key value is only displayed once, and you will not be able to retrieve it later
14.Click on Requires Permission
15.Configure Permissions – under the “Permissions to other applications” section, you will configure permissions to access the Graph (Windows Azure Active Directory). For “Windows Azure Active Directory” under the first permission column (Application Permission:1″), select “Read directory data”. Notes: this configures the App to use OAuth Client Credentials, and have Read access permissions for the application.Select the Save button at the bottom of the screen – upon successful configuration, your Key value should now be displayed – please copy and store this value in a secure location.
16.Click on Save
17.Click on grant permission from the Global administrator or Company administrator role.
18.Once permission is granted, click on manifest
19.Find  “oauthAllowImplicitFlow” set to true and save
Open Visual Studio -> File->Project->Select Console App->Give name and location->Ok
– Add Microsoft.identityModel.Clients.ActivityDirectory to console application
Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory -Version 3.19.8.

Add following constant values in to the constants.cs file

public const string TenantName = “samplesolution.onmicrosoft.com”;
public const string TenantId = “8f4455df-8ae6-454d-bd00-e53e5f87f050”;
public const string ClientId = “3db07cc2-3c44-4f13-ca43-8edcbe130a29”;
public const string ClientSecret = “ItcmltZpNj4UiRItqJUsT8P2G3Fx6HY9RCU/l9vizpQ=”;
public const string ResourceUrl = “https://graph.windows.net”;
public const string authority=”https://login.windows.net/”CommonConstants.TenantName;

ClientID = Application ID which we have store in separate file.
Secret key = key value which we have get from azure portal while generate the key.Code to create a ActiveDirectoryClient

using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Net.Http.Headers;
using System.Threading.Tasks;static void Main(string[] args)
ActiveDirectoryClient activeDirectoryClient = GetActiveDirectoryClientAsApplication();

// Get user based on email address.
// We can get the user from Azure AD using below method.We can get user based on UPN(User Principal Name,UserType) ;
Microsoft.Azure.ActiveDirectory.GraphClient.User user = (Microsoft.Azure.ActiveDirectory.GraphClient.User)activeDirectoryClient.Users.Where(u => u.Mail.Equals(mailAddress)).ExecuteAsync().Result.CurrentPage.FirstOrDefault();

// Get application from the Azure AD which we have configured earlier.
Application application = (Application)activeDirectoryClient.Applications.Where(app => app.AppId.Equals(Constants.CommonConstants.ClientId)).ExecuteAsync().Result.CurrentPage.FirstOrDefault();

// Get approle from selected application
// App role is define in to the manifest file.
AppRole appRole = application.AppRoles.Where(role => role.Id.Equals(Guid.Parse(Constants.ApplicationConstants.AppRoleID))).FirstOrDefault();

// We can create new app role from below code.
//Create App Role
AppRole appRole = new AppRole();
appRole.Id = Guid.NewGuid();
appRole.IsEnabled = true;
appRole.DisplayName = “Something”;
appRole.Description = “Anything”;
appRole.Value = “policy.write”;

// Get Service principal from active directory

ServicePrincipal servicePrincipal = (ServicePrincipal)activeDirectoryClient.ServicePrincipals.Where(service => service.AppId.Equals(Constants.CommonConstants.ClientId)).ExecuteAsync().Result.CurrentPage.FirstOrDefault();

// Assign user to application in azure active directory
AppRoleAssignment appRoleAssignment = new AppRoleAssignment();
appRoleAssignment.Id = appRole.Id;
appRoleAssignment.ResourceId = Guid.Parse(servicePrincipal.ObjectId);
appRoleAssignment.PrincipalType = “User”;
appRoleAssignment.PrincipalId = Guid.Parse(user.ObjectId);

public static ActiveDirectoryClient GetActiveDirectoryClientAsApplication()
ActiveDirectoryClient activeDirectoryClient = new ActiveDirectoryClient(new Uri(new Uri(Constants.AzureConstants.ResourceUrl), Constants.CommonConstants.TenantId),
async () => await AcquireTokenAsyncForApplication());
return activeDirectoryClient;


public static async Task<string> AcquireTokenAsyncForApplication()
return GetAccessTokenAzure();

public static string GetAccessTokenAzure()
AuthenticationContext authContext = new AuthenticationContext(Constants.AzureConstants.authority, null);
ClientCredential creds = new ClientCredential(Constants.CommonConstants.ClientId, Constants.CommonConstants.ClientSecret);

AuthenticationResult authenticationResult = authContext.AcquireTokenAsync(Constants.AzureConstants.ResourceUrl, creds).Result;
string accessToken = authenticationResult.AccessToken;
return accessToken;

Happy Coding 🙂

Add New Theme in Modern Site


Steps to follow change the theme in SharePoint online modern sites

Step 1:

First, make sure you have the latest version of the SharePoint Online Management Shell

Step 2:

Connect environment to power shell

 $adminUPN=”<Admin User Name>” e.g. demo@test.onmicrosoft.com 

$orgName=”<name of your Office 365 organization>” e.g. test

$userCredential = Get-Credential -UserName $adminUPN -Message “Type the password.” 

Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential

Step 3:

Run below command to check version of SharePoint management shell.


If you do NOT get an error, but get either “true” or “false,” then you can continue. If you DO get an error, then uninstall your version of the SharePoint Online Management Shell and then download and install the latest version

Step 4:

Go to Microsoft’s online tool for generating Modern theme colors. Play with the sliders or enter in your own color codes for the primary, body, and text colors. Scroll down to the bottom part of the page to see how your color choices affect the UI elements.



Step 5:

Highlight and copy the Power Shell variables. (If you want a multi-colored theme, you won’t be able to make any additional custom changes to the colors in this interface, but you can copy the code into a text editor and make manual changes to the variables there.

Step 6:

Run PowerShell Command as below

$themepalette = @{

“themePrimary” = “#927098”;

“themeLighterAlt” = “#f7f5f8”;

“themeLighter” = “#ece5ed”;

“themeLight” = “#d0c1d3”;

“themeTertiary” = “#ae95b2”;

“themeSecondary” = “#98779d”;

“themeDarkAlt” = “#85648b”;

“themeDark” = “#5f4763”;

“themeDarker” = “#523d55”;

“neutralLighterAlt” = “#f8f8f8”;

“neutralLighter” = “#f4f4f4”;

“neutralLight” = “#eaeaea”;

“neutralQuaternaryAlt” = “#dadada”;

“neutralQuaternary” = “#d0d0d0”;

“neutralTertiaryAlt” = “#c8c8c8”;

“neutralTertiary” = “#d0c1d3”;

“neutralSecondary” = “#ae95b2”;

“neutralPrimaryAlt” = “#98779d”;

“neutralPrimary” = “#927098”;

“neutralDark” = “#5f4763”;

“black” = “#523d55”;

“white” = “#ffffff”;

“primaryBackground” = “#ffffff”;

“primaryText” = “#927098”;

“bodyBackground” = “#ffffff”;

“bodyText” = “#927098”;

“disabledBackground” = “#f4f4f4”;

“disabledText” = “#c8c8c8”;


Add-SPOTheme -Name “Your Theme Name” -Palette $themepalette -IsInverted $false

Step 6:

That’s it! This now adds the theme to your tenant, and you can access it from the “Change the look” panel. 

HaPpy Coding 🙂


Upload Document using c# code to Share-Point library

Hello everyone,

I was facing the following exception.So i had searched and got the solution.

Only String, int, and DateTime data types can be used as the value in Properties while adding list item in document library.

I am including following concept with this blog.

1) how to upload document in to SharePoint library from the other library.
2) pass the document metadata using hash table.
3) How to update custom field of SharePoint library with uploaded document.
4) Limitations of Files.Add() methods with hash table.

Key Concept :
What is hash Table?

  • The Hashtable class represents a collection of key-and-value pairs that are
  • organized based on the hash code of the key.
  • It uses the key to access the elements in the collection.
  • A hash table is used when you need to access elements by using key, and you can identify a useful key value.
  • Each item in the hash table has a key/value pair.
  • The key is used to access the items in the collection.

1)How can I upload document in to the Document library from the other document library and update Document library meta data in share point?
2)How can I update document library custom field with user type and Date time type Using c# code?
Let’s take document library:
1) UserInformation(Destination Library)
Custom Fields : 1) DocUpdateDate: DateTime 2)DocAddedBy: User
2) BioData(Source library)


//Get the Source library
 SPList BioData = elevatedWeb.Lists.Cast().FirstOrDefault(l => l.id == listID);
 if (bioData!=null)
 spListItem bioDataItem = bioData.GetItemById(itemID);
 // get file from the item which you want to upload the destination.
 SpFile objFile = Item.File;
 string fileName = objFile.Name;
 //Getting latest published version file content
 byte[] fileContent = null;
 if (objFile.UIVersionLabel.Contains(".0"))
 fileContent = file.OpenBinary();
 string versionString = string.Format("{0}.0", objFile.MajorVersion.ToString());
 SPFileVersion version = objFile.Versions.GetVersionFromLabel(versionString);
 fileContent = version.OpenBinary();
 // Now open the Destination library where you want to upload document.
 SpList UserInformation = elevatedWeb.Lists.Cast().FirstOrDefault(l => l.ID == listID);
 // create a hastable to stored the Document metadata.
 HashTable properties = new HashTable();
 // Add metadata key and value of the document.
 // you can number of properties as per the business requirement.
 // now upload the document in to the library.
 // to upload the file ,open the object of the SpFile.
 elevatedWeb.AllowUnsafeUpdates = true;
 SpFile uploadFile = UserInformation.RootFolder.Files.Add(fileName, fileContent, properties);



Limitations of Files.Add() methods with hash table.
If I add a column of type Currency then the code will break and it won’t add the list item to the library at all.Because the function list.RootFolder.Files.Add() will not accept the properties other than the 3 types mentioned,through HashTable
This is the problem with the function. To avoid that below is the code i used and this problem went away.


// create a SPListItem object from the objFile.
spListItem objListItem = uploadFile.Item;
objListItem[“DocUpdateDate”] = DateTime.Now;
// update list item
elevatedWeb.AllowUnsafeUpdates = false;


Finally, updating the list item and updating the file to reflect the changes to the document library list items.

Please feel free to post your ideas, comments and question here.

Happy Coding 🙂

Copy Document and metadata From one library to Other library using Nintex

Hello Tech People,

I am explaining about Nintex Work Flow which is using in share point to fulfill most of the business requirement.

What is Nintex?

Requirement : 

How can i copy Document and metadata of Document library in share point to other Document library ?

In simple language i have Two Document libraries.

Requirement Of nintex WorkFlow

Requirement Of nintex WorkFlow

I hope you got Requirement carefully.

Solution : 

I m going with the assumption that , Every one has created Two Document library. 1) Source 2) Destination

Click on SourceList -> Click on library in Top Ribbon -> Click on Workflow Setting – >  Create nintex Workflow.


You have to install nintex if you don’t have . Other Wise “Create Workflow in nintex workflow” is not displayed.

And If your system has already nintex . after that you have to active some feature at site collection level which is regarding nintex.


now click on “Create WorkFlow in nintex workflow” nintex Workflow screen will be open .

— > Select Blank WorkFlow and give it Unique Name.After create you can see display which i have define below.


— > Search “Copy to Sharepoint” In Search box . Drag the symbol and put it on Workflow. and name it “Copy Metadata from one Document To Other.” (you can give as per your mood also.)


now click on ARWDOWN in Workflow and Set necessary configuration to fulfill the requirement.


  1. Select Destination :  You have to pass the URl of the Destination Document Library .
  2. over-Write option : 1) Remove existing item 2) Rename new item 3) Update Existing item
  3. Check Create folder Structure
  4. Check Copy In MetaData

Last Step Save the WorkFlow -> Publish it – > Add item to document library – >Check Destination Library 

Note : Nintex Workflow Develop only in IE. 

Have any query , feel free to ask me .

Happy Coding 🙂

Apply Slider in Content Query Web part(CQWP) using XSL

Hello everyone ,

I hope, You are well and doing good.

What is CQWP?

SharePoint Content Query Web Part (CQWP) is a powerful tool to display aggregated content from various SharePoint pages, lists and libraries .

Note : More Information regarding cqwp 


Now i am here to explain you how to get List item from SharePoint list and library and display it in Content Query Web part  with attractive manner and  user friendliness.

Now, i have a question .How can i make it attractive manner ? Right . Let me Explain You. I want to tell you that , In attractive manner means put some animation,Give effect with sliding etc etc.

Business Requirement :

I have one share point list name with NewsList. Now i want to display data in “Newslist” on my home page with sliding effect. E.g   I have 5 records in NewsList and I have to display Top 3 records in CQWP . Only one record display in one slide.Slider has to be automatically working . Display field of NewslIst is “Title”, “Date” and “NewsContent” . If  “NewsContent” is more than 40 Characters , than Only 40 characters can be in slider and must be a link Read More… Below that.

I  Hope , Everyone is clear with Requirement. Now i am going to describe solution to fulfill this requirement. There is two way : 1)Add Script Editor to with content query web part and load necessary .js file to share point . 2) Add and load .js file using XSL . I  have prefer second way for get output Solution : Step :1

  •  You have to create one list or library in your share point site.
  • After that you have to select content Query Web part in your page where you want to implement slider

Note: If you are working on TeamSite than you have to activate two features to use CQWP .  1) SharePoint Server publishing infrastructure.(Site level) 2) SharePoint server publishing(Web level) But if you are using Publishing Site than no worry . Two features automatically activated by share point.

  •  Now, You have to configure such setting to get list records in CQWP.

Step : 1

CQWP Steps to open CQWP Tool Part : Edit Page –> Click on Edit Web part –> Tool part is open in left side of your page

Now you have to set path of resource from which you want to take data and show it in to CQWP. Either it is list or Library.

Step : 2

You have to  Export webpart.

Steps to export webpart.

Edit Page -> Edit Webpart ->Click on Export Button ->Web part exported successfully in your local macNow you h


Open Exported .webpart file in share-point designer or in other tool like note or notepad++.

Step : 3

You have to change value of two properties in .webpart. You have to change value of this properties if you are using your custom “itemstyle.xsl” or “contentquerymain.xsl” . if you are using default file than you have not to change it.

1)ItemXslLink   2)MainXslLink

Set your itemstyle.xsl file path in itemslLink and contentquerymain.xsl in Mainxsllink. You can see in image .


Close the.webpart fie and upload webpart in sharepoint.

Edit Page -> Insert -> Click on webpart ->Click on upload webpart -> select webpart -> Click on Upload 

Upload webpart

Step : 4

Now open Itemstyle.xsl To put your login for slider.

I had use Jassor.slider to display data with sliding . You can use any other slider to display data.

Here , Create your custom template to display data in ItemStyle.xsl. i have created SliderTemplate . Here CurPos and LastRaw is two parameter to give some css  or display data in some manner.

This Two parameter is define in contentmain.xsl.







Note :Why is it necessary to create and call “removemarkup”?

If you are direct get data from body field in announcement list than you can get string with some html tag and special character which is not understandable by non-technical person. So we have to remove this type of tag and special character

So i have to remove this type of tags using “removeMarkUp” template. you can use it as per your requirement.


Now  Open your site . open Wenpart Tool panal . and check your custom template is present or not.


If Template is displayed in drop down . That means you have successfully  configures custom template to the web part. You can see slider on page with necessary data.

Kindly contact me if have any query regarding this post.

Happy Coding 🙂

Bind ColorPicker Control to the sharepoint List field using JSlink

Hello Developers…

I am back to share something new things with you guys. and i am pleasure to sharing.

Today , First of all i m explaining you what is the business requirement .

Definition : I have created custom list(ColorList) in share point  . In this there are two column Title and Color. in the Color column type is Text . now i want to render Color column with color-picker control and save the color code to the share point list  with # . I have uploaded image below.


You can see what i want as an output.  right ?

Solution : 

first of all i have searched lots of colorpicker.js . At last i have download jquery.colorpicker.js and used it because this Js file give me almost all the functionality which is i required.


You can find of colorpicker.js from this link .

Once JS is decided upload JS file to share point _catalog folder with proper naming convention . Open Your url in share point designer and Click on “All Files” -> Click on “_catalog” -> Drag An Drop Your file to this folder. Folder is automatically uploaded to the your share point server.

You have to all necessary files upload in share point.

List of files you have to include in share point.

1) colorpicker.css



4)Images of Color picker and layout js in proper folder.

now, open your SharePoint Page on which you want to apply Js link . That must be One or more from the three pages.




i have write on NewForms.aspx to fulfill requirement.

Now open NewForms in Edit mode.


Right Click On Edit Web part -> select Miscellaneous -> Add Jslink to JSlink Tab -> Save ->Stop editing.

This is the process to bind jslink to NewForm.aspx.

Now i am explaining , What is JSlink in share point ?

-> Jslink  is simple java script to render your control with more user friendliness and attractive. you can use Jsquery,AngualrJS whatever you ant to implement.It’s a purely combination of CSS and JS File for client side rendering.

->You can apply lots of combination to the share point default pages .

What Jslink do excatly?

-> Jslink simply override your control with share-point control .

Now i m coming on code,


(function () {
// Intialize the variables for overrides objects
var overrideCtx = {};
overrideCtx.Templates = {};
//overrideCtx.OnPostRender = [];
//overrideCtx.OnPostRender.push(function(){OnPostRenderFunc(); });
// Override field data
overrideCtx.Templates.Fields = {
‘Color’:   //Color is our field name which will replace by the color picker control .
‘NewForm’: ingredientsNewAndEdit // ingredientsNewAndEdit function to render our HTMl to sharepoint Newforms,aspx
overrideCtx.OnPostRender = postRenderHandler;
// Register the override of the field
function ingredientsNewAndEdit(Ctx)
var string = “/_catalogs/masterpage/layout.css,/_catalogs/masterpage/colorpicker.css”
for(var i=0 ; i<string.split(“,”).length;i++)
var link = document.createElement(‘link’);
link.id = “Css” + i;
link.rel = ‘stylesheet’;
link.type = ‘text/css’;
link.href = string.split(“,”)[i].toString();
document.getElementsByTagName(‘head’)[0].appendChild(link); //Load CSS file pro-grammatically.
var formCtx = SPClientTemplates.Utility.GetFormContextForCurrentField(ctx);
var FieldHtml=”<p><div id=’colorSelector’><div style=’background-color: #0000ff’></div></div></p>”
return FieldHtml;

function postRenderHandler(ctx)
if(ctx.ListSchema.Field[0].Name == “Color”)
color: ‘#0000ff’,
onShow: function (colpkr) {
return false;
onHide: function (colpkr) {
return false;
onChange: function (hsb, hex, rgb) {
$(‘#colorSelector div ‘).css(‘backgroundColor’, ‘#’ + hex);




Once your HTMl Control render successfully on page after that you can get that control using this property with out _postback, So you can manipulate with the control’s value property .

It’s amazing datepicker control .


You can see the output.

If have any query or suggestion  regarding code , feel free to ask.


Happy Coding 🙂

Manipulation with Sharepoint List with flavored of AngularJS and ng-Grid

Hello Developers !!!

i am sharing with such things which i have implemented. i have played with  SharePoint2013 , angularJS and ng-grid and that was seriously amazing.

Now i am going to explain scenario which i have implemented.

What u do If your client require to display SharePoint list data with CEWP(Content Editor web part) and it must be user friendly with highest look and feel ? 

I guess , you guys understand the requirement carefully!!! Now i going to one step ahead . . . .

After listening the requirement , i just thinking which JS has to implement to fulfill Requirement, i have many option like NODE.JS , Angular.JS, JQuery etc . . So i think and tell my self.

Let’s Dipen , ready to Play with Angular.JS

now i have create one custom list in Sharepoint2013. i m not explaining you this thing , because i think it’s out of the track part . but i provide you link to refer for creating list.


Now, how many things you have to want to implement this things.

1) Index.HTML //To display the content in CEWP


3)ng-grid.Js and ng-grid.css

4)If  you wan to add bootsrap than call bootstrap.css

5) main.js  // your Scripting Logic and events are handled int his js file

now , i mention below index.HTMl File which i have created.


<!DOCTYPE html>
<html ng-app=”myApp”>
<head lang=”en”>
<link data-require=”bootstrap-css@3.2.0″ data-semver=”3.2.0″ rel=”stylesheet” href=”bootstrap.min.css”/>
<link rel=”stylesheet” type=”ng-grid.css”/>
<link rel=”stylesheet” type=”text/css” href=”style.css”/>
<script src=”jquery-1.8.2.js” type=”text/javascript”></script> // not necessary to add
<script src=”angular.js” type=”text/javascript”></script>
<script type=”ng-grid-1.3.2.js”></script>
<script type=”main.js”></script>
<body ng-controller=”MyCtrl”>
<div class=”gridStyle” ng-grid=”gridOptions”></div>

Step 1 : Here ,  i have declare one <div> and class=”gridStyle” grid style is a inbuilt class of the Angular ng-grid.

  • ng-app : Root Element of the HTML.The first ngApp found in the document will be used to define the root element to auto-bootstrap as an application.The ngApp directive designates the root element of the application and is typically placed near the root element of the page – e.g. on the <body> or<html> tags.

  • ng-Controller: Actually AngularJs is working on basic concept of Modal , View and Controller . ng-Controller is a inbuild property in angular. Now,You have question Right ? Why it is necessary to write? Exactly, it is most important . if you are not include than you can not use your Scripting logic with HTMl element.

    The ngController directive specifies a Controller class.The class contains business logic behind the application to decorate the scope with functions and values.The type of the ng-Controller is “Expression“. ng-controller="as propertyName".

  • ng-grid=”gridOption” is a inbuilt property in Angular. “gridoption” is custome option list which is created by coder in custom js File . ii know you guys are little bit panic or confuse , but trust me , Honestly saying You can understand better , how to work this at end of the post .


var app = angular.module(‘myApp’, [‘ngGrid’]); // myApp is our Root Element of the HTML. Ican say it’s Container to contain the element and data binding.
app.controller(‘MyCtrl’, function($scope,$http) { // Myctrl is controller
method: ‘GET’,
url: _spPageContextInfo.webAbsoluteUrl + “/_api/web/lists/getByTitle(‘Task’)/items?$select=Title,CustomDate,Modified”, //rest Api to get the a Data from the Sharepoint list .
headers: { “Accept”: “application/json;odata=verbose” }
}).success(function (data, status, headers, config) {
$scope.totalServerItems = data.d.results;
}).error(function (data, status, headers, config) {
alert(“Error Occured” + “Status Code = ” + Status);
$scope.gridOptions = {
data: ‘totalServerItems ‘,
columnDefs: [
{field: ‘Title’, displayName: ‘Title’},
{field: ‘CustomDate’, displayName: ‘Date’,cellFilter: ‘date:\’dd-MMM-yyyy\”}]

$scope,$http ? What is it ?  . . Wait wait wait … i m going explain it in detail . . . 🙂

Scope As Data-modal :

Scope is the glue between application controller and the view.Both controllers and directives have reference to the scope, but not to each other. This arrangement isolates the controller from the directive as well as from the DOM.

$http A Service

The $http service is a core Angular service that facilitates communication with the remote HTTP servers via the browser’s XMLHttpRequest object .Simple language it use to get data from external sources.


Column Definition to display the column to gird.There’s  bunch of options available in angular . you can utilize it depending on your requirement.I have used Field which is display no of  column to grid .

Field has two property : 1)field : which is column name which you want to display data or ic an sat binding of data. 2) displayName which renders  the column header or Title on page .

You can find other option From bellow link .


now you can Call this index.HTMl file to  Content Editor Web part . and Refresh the page . . . You can see list of data in CEWP and That will be amazing. . .

I  tried my best to describe the concept.I hope, you guys enjoyed this blog . If have an any query , kindly leave your comment.

Happy Coding 🙂

How to Validate XmlNodes in Xml Document?

We have to clear about terms “XMLNodes” and “XMLDocument”.

XMLDocument : very simple way any file with extension .xml is a “XMLDocument”.

And Every XMlDoc has an one or more XMLNodes.

Let me Explain in Brief….

Let’s Guess here a XMlDocument Test.xml

<Test>   //Test is known as a XMlNode.
     <Test1>  // Test1 known as  a childnode of XMlnode Test.
            ID=”1″,     // Id and name known as Xml Attribute of Test1 node.
Now you are understand basic concept of XMlNodes and XmlDoc.

Now fetch the Xml file from user or from source to validate the XMlnodes,

     You have to import Using Microsoft.XML;  // Namespace

var Doc = new XmlDocument();  // Variable to store the XmlDocument.
Doc.Load(“//Test.xml”); // To load our Xml file to Console application.
XmlNodeList AllfieldTags = Doc.GetElementsByTagName(“Test”);//Get all the child Nodes of the Test Node.
foreach(XmlNode CurrentFields in AllFieldTag)
Public static class Validate(XmlNode Current)
     XmlNodelist list= Current.ChildNodes;
    for (int Index = 0; Index < list.Count; Index++)
for (int SubIndex = Index + 1; SubIndex < list.Count – 1; SubIndex++)
if ((list[Index].Attributes[“ID”].Value ==                     list[SubIndex].Attributes[“ID”].Value) ||       (list[Index].Attributes[“Name”].Value ==     list[SubIndex].Attributes[“Name”].Value))
flag = true;
if (flag == true)
if (flag == true)
return false;
return true;

U can Validate attribute value in XMl File Using For loop as i mention above code.

:):)!!Happy Coding!!:):)