Description

Updating a Processing Instruction

Demo

using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;

class Program/* w  w  w  .  j ava 2 s  .c  om*/
{
    static void Main(string[] args){
        //  we will use this to store a reference for later access.
        XProcessingInstruction procInst;
        
        XDocument xDocument = new XDocument(
          new XElement("Books"),
          procInst = new XProcessingInstruction("BookCataloger", "out-of-print"));
        
        Console.WriteLine("Before updating processing instruction:");
        Console.WriteLine(xDocument);
        
        procInst.Target = "BookContactManager";
        procInst.Data = "update";
        
        Console.WriteLine("After updating processing instruction:");
        Console.WriteLine(xDocument);
    }
}

Result

Related Topic