none
Set XML Token using PowerShell

    Question

  • I have to programmatically modify an XmL file based on instructions given here

    http://support.microsoft.com/kb/940958

    You will notice that I need to open a XML file called ONET.xml and then go to the element called Project.

    Now here I have to set

    DisableWebDesignFeatures=wdfopensite

    So that the Project element looks like

    <Project Title="Team Web Site" ListDir="Lists" xmlns:ows="Microsoft SharePoint" DisableWebDesignFeatures=wdfopensite>

    Now I wrote this code as 

    [xml] $dom = get-content onet.xml

    $dom.Project.SetAttribute("DisableWebDesignFeatures", "wdfopensite")

    But this created an Project Element like 

    <Project Title="Team Web Site" ListDir="Lists" xmlns:ows="Microsoft SharePoint" DisableWebDesignFeatures="wdfopensite">

    But this gave me problem and I checked with forums and was informed that wdfopensite has to be added without " marks like shown in first sample.

    I am very confused how can I set the Project element with DisableWebDesignFeatures=wdfopensite

    The word used was that this done as a Token rather than attribute

    but I have no clue of how to set a token programmatically using powershell.


    MSDNStudent Knows not much!


    Thursday, June 14, 2012 9:03 PM

Answers

  • Hi,

    Please try the below code first and check out the properties that it has:

    $dom.Project |get-member

    Then according to the output, set the proper attribute to the proper value.

    Please post the output here for analysis.

    Regards,

    Yan Li


    Yan Li

    TechNet Community Support

    Thursday, June 21, 2012 2:36 AM