Tagged: xml and powershell
- August 28, 2016 at 10:36 am #52254
Hi! I have run into a XML problem(Not yet good enough to contribute, hopefully, I will be someday!). I have used the get-content cmdlet and opened up a file in xml using [xml], stuck it in a $variabel and so forth. Managed to address two nodes and change the value by drilling down the hierarchy to.....childnodes.Item(nr). No problem so fare, but what about hte third node, a node named "XmlDefinition"? This is of type string containing some CAML(I think) and two "values" I would like to replace (I use the file in SP deployments). The node and the string looks like this:
IwanttoreplacethisGUID}" MobileView="TRUE" Type="HTML" Hidden="TRUE" DisplayName="" Url="IwanttoreplacethisURL" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/dlicon.png?rev=43" >30clienttemplates.jsmain.xsl
Question: How would I address ONLY the 2 highlighted pieces of information, replace the GUID and the URL, save the file, using just PowerShell? I have tried getting to it by innertext,data and outerxml and use the replace operator, but no luck. It's not a big deal if it does no work – I get the job done by get-content and set-content, but I dont think this is the right approach.
I am just pissed off by this IT brick wall.
Well, there you have it...
Wish you all well
/C.August 28, 2016 at 1:17 pm #52272
I think I can help you if you post the full XML (sanitize any confidential details) on an external site like PasteBin, TinyPaste, Hastebin or Gist and link to it here.
Thanks very much.
You must be logged in to reply to this topic.