Description

Updating a Processing Instruction

Demo

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

class Program//from  ww w .j a v a  2 s  .  co m
{
    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