Hi everyone,
First of all, sorry for my english i'm a french user and I find no community in French to talk about my problem :
I have an XML file like this :
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<pubs>
<pub consumid="title" cover="21_07_2014/data/cover.jpg" coverthmb="21_07_2014/data/coverthmb.jpg" date="20140721" dummies="21_07_2014/ipad_dummies.xml" id="104263" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="22_07_2014/data/cover.jpg" coverthmb="22_07_2014/data/coverthmb.jpg" date="20140722" dummies="22_07_2014/ipad_dummies.xml" id="104302" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="23_07_2014/data/cover.jpg" coverthmb="23_07_2014/data/coverthmb.jpg" date="20140723" dummies="23_07_2014/ipad_dummies.xml" id="104303" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="24_07_2014/data/cover.jpg" coverthmb="24_07_2014/data/coverthmb.jpg" date="20140724" dummies="24_07_2014/ipad_dummies.xml" id="104186" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="25_07_2014/data/cover.jpg" coverthmb="25_07_2014/data/coverthmb.jpg" date="20140725" dummies="25_07_2014/ipad_dummies.xml" id="104404" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="26_07_2014/data/cover.jpg" coverthmb="26_07_2014/data/coverthmb.jpg" date="20140726" dummies="26_07_2014/ipad_dummies.xml" id="104265" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="28_07_2014/data/cover.jpg" coverthmb="28_07_2014/data/coverthmb.jpg" date="20140728" dummies="28_07_2014/ipad_dummies.xml" id="104422" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="29_07_2014/data/cover.jpg" coverthmb="29_07_2014/data/coverthmb.jpg" date="20140729" dummies="29_07_2014/ipad_dummies.xml" id="104443" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="30_07_2014/data/cover.jpg" coverthmb="30_07_2014/data/coverthmb.jpg" date="20140730" dummies="30_07_2014/ipad_dummies.xml" id="104444" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="31_07_2014/data/cover.jpg" coverthmb="31_07_2014/data/coverthmb.jpg" date="20140731" dummies="31_07_2014/ipad_dummies.xml" id="104462" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="01_08_2014/data/cover.jpg" coverthmb="01_08_2014/data/coverthmb.jpg" date="20140801" dummies="01_08_2014/ipad_dummies.xml" id="104482" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="02_08_2014/data/cover.jpg" coverthmb="02_08_2014/data/coverthmb.jpg" date="20140802" dummies="02_08_2014/ipad_dummies.xml" id="104502" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="04_08_2014/data/cover.jpg" coverthmb="04_08_2014/data/coverthmb.jpg" date="20140804" dummies="04_08_2014/ipad_dummies.xml" id="104522" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="05_08_2014/data/cover.jpg" coverthmb="05_08_2014/data/coverthmb.jpg" date="20140805" dummies="05_08_2014/ipad_dummies.xml" id="104542" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="06_08_2014/data/cover.jpg" coverthmb="06_08_2014/data/coverthmb.jpg" date="20140806" dummies="06_08_2014/ipad_dummies.xml" id="104543" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="07_08_2014/data/cover.jpg" coverthmb="07_08_2014/data/coverthmb.jpg" date="20140807" dummies="07_08_2014/ipad_dummies.xml" id="104562" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="08_08_2014/data/cover.jpg" coverthmb="08_08_2014/data/coverthmb.jpg" date="20140808" dummies="08_08_2014/ipad_dummies.xml" id="104582" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="09_08_2014/data/cover.jpg" coverthmb="09_08_2014/data/coverthmb.jpg" date="20140809" dummies="09_08_2014/ipad_dummies.xml" id="104602" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="11_08_2014/data/cover.jpg" coverthmb="11_08_2014/data/coverthmb.jpg" date="20140811" dummies="11_08_2014/ipad_dummies.xml" id="104622" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="12_08_2014/data/cover.jpg" coverthmb="12_08_2014/data/coverthmb.jpg" date="20140812" dummies="12_08_2014/ipad_dummies.xml" id="104642" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="13_08_2014/data/cover.jpg" coverthmb="13_08_2014/data/coverthmb.jpg" date="20140813" dummies="13_08_2014/ipad_dummies.xml" id="104643" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="14_08_2014/data/cover.jpg" coverthmb="14_08_2014/data/coverthmb.jpg" date="20140814" dummies="14_08_2014/ipad_dummies.xml" id="104665" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="15_08_2014/data/cover.jpg" coverthmb="15_08_2014/data/coverthmb.jpg" date="20140815" dummies="15_08_2014/ipad_dummies.xml" id="104702" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="16_08_2014/data/cover.jpg" coverthmb="16_08_2014/data/coverthmb.jpg" date="20140816" dummies="16_08_2014/ipad_dummies.xml" id="104723" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="18_08_2014/data/cover.jpg" coverthmb="18_08_2014/data/coverthmb.jpg" date="20140818" dummies="18_08_2014/ipad_dummies.xml" id="104782" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
</pubs>
I just want a simple thing : deleting the nodes where dates are more than 15 days (2 weeks). Like in this example, i only want nodes where dates are between "20140802" and "20140818". The result can be in an other XML file or directly applied in the already existing XML file.
I'm a newbie using PowerShell, but i already found some interesting commands like these ones :
$xml = [xml](Get-Content E:\ipadpub.xml)
$datations = $xml.pubs.pub | % {$_.date -ge {(Get-Date).adddays(-15)}} | $xml.Save("E:\test.xml")
I'm testing many others commands but i'm unsucessful :(
Can anyone give me some good tips in a way to solve my problem, it would be nice.
Regards,
Jf
First of all, sorry for my english i'm a french user and I find no community in French to talk about my problem :
I have an XML file like this :
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<pubs>
<pub consumid="title" cover="21_07_2014/data/cover.jpg" coverthmb="21_07_2014/data/coverthmb.jpg" date="20140721" dummies="21_07_2014/ipad_dummies.xml" id="104263" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="22_07_2014/data/cover.jpg" coverthmb="22_07_2014/data/coverthmb.jpg" date="20140722" dummies="22_07_2014/ipad_dummies.xml" id="104302" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="23_07_2014/data/cover.jpg" coverthmb="23_07_2014/data/coverthmb.jpg" date="20140723" dummies="23_07_2014/ipad_dummies.xml" id="104303" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="24_07_2014/data/cover.jpg" coverthmb="24_07_2014/data/coverthmb.jpg" date="20140724" dummies="24_07_2014/ipad_dummies.xml" id="104186" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="25_07_2014/data/cover.jpg" coverthmb="25_07_2014/data/coverthmb.jpg" date="20140725" dummies="25_07_2014/ipad_dummies.xml" id="104404" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="26_07_2014/data/cover.jpg" coverthmb="26_07_2014/data/coverthmb.jpg" date="20140726" dummies="26_07_2014/ipad_dummies.xml" id="104265" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="28_07_2014/data/cover.jpg" coverthmb="28_07_2014/data/coverthmb.jpg" date="20140728" dummies="28_07_2014/ipad_dummies.xml" id="104422" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="29_07_2014/data/cover.jpg" coverthmb="29_07_2014/data/coverthmb.jpg" date="20140729" dummies="29_07_2014/ipad_dummies.xml" id="104443" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="30_07_2014/data/cover.jpg" coverthmb="30_07_2014/data/coverthmb.jpg" date="20140730" dummies="30_07_2014/ipad_dummies.xml" id="104444" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="31_07_2014/data/cover.jpg" coverthmb="31_07_2014/data/coverthmb.jpg" date="20140731" dummies="31_07_2014/ipad_dummies.xml" id="104462" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="01_08_2014/data/cover.jpg" coverthmb="01_08_2014/data/coverthmb.jpg" date="20140801" dummies="01_08_2014/ipad_dummies.xml" id="104482" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="02_08_2014/data/cover.jpg" coverthmb="02_08_2014/data/coverthmb.jpg" date="20140802" dummies="02_08_2014/ipad_dummies.xml" id="104502" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="04_08_2014/data/cover.jpg" coverthmb="04_08_2014/data/coverthmb.jpg" date="20140804" dummies="04_08_2014/ipad_dummies.xml" id="104522" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="05_08_2014/data/cover.jpg" coverthmb="05_08_2014/data/coverthmb.jpg" date="20140805" dummies="05_08_2014/ipad_dummies.xml" id="104542" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="06_08_2014/data/cover.jpg" coverthmb="06_08_2014/data/coverthmb.jpg" date="20140806" dummies="06_08_2014/ipad_dummies.xml" id="104543" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="07_08_2014/data/cover.jpg" coverthmb="07_08_2014/data/coverthmb.jpg" date="20140807" dummies="07_08_2014/ipad_dummies.xml" id="104562" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="08_08_2014/data/cover.jpg" coverthmb="08_08_2014/data/coverthmb.jpg" date="20140808" dummies="08_08_2014/ipad_dummies.xml" id="104582" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="09_08_2014/data/cover.jpg" coverthmb="09_08_2014/data/coverthmb.jpg" date="20140809" dummies="09_08_2014/ipad_dummies.xml" id="104602" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="11_08_2014/data/cover.jpg" coverthmb="11_08_2014/data/coverthmb.jpg" date="20140811" dummies="11_08_2014/ipad_dummies.xml" id="104622" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="12_08_2014/data/cover.jpg" coverthmb="12_08_2014/data/coverthmb.jpg" date="20140812" dummies="12_08_2014/ipad_dummies.xml" id="104642" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="13_08_2014/data/cover.jpg" coverthmb="13_08_2014/data/coverthmb.jpg" date="20140813" dummies="13_08_2014/ipad_dummies.xml" id="104643" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="14_08_2014/data/cover.jpg" coverthmb="14_08_2014/data/coverthmb.jpg" date="20140814" dummies="14_08_2014/ipad_dummies.xml" id="104665" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="15_08_2014/data/cover.jpg" coverthmb="15_08_2014/data/coverthmb.jpg" date="20140815" dummies="15_08_2014/ipad_dummies.xml" id="104702" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="16_08_2014/data/cover.jpg" coverthmb="16_08_2014/data/coverthmb.jpg" date="20140816" dummies="16_08_2014/ipad_dummies.xml" id="104723" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
<pub consumid="title" cover="18_08_2014/data/cover.jpg" coverthmb="18_08_2014/data/coverthmb.jpg" date="20140818" dummies="18_08_2014/ipad_dummies.xml" id="104782" name="" num="" productid="GVNP" sproductid="$unavailable$"/>
</pubs>
I just want a simple thing : deleting the nodes where dates are more than 15 days (2 weeks). Like in this example, i only want nodes where dates are between "20140802" and "20140818". The result can be in an other XML file or directly applied in the already existing XML file.
I'm a newbie using PowerShell, but i already found some interesting commands like these ones :
$xml = [xml](Get-Content E:\ipadpub.xml)
$datations = $xml.pubs.pub | % {$_.date -ge {(Get-Date).adddays(-15)}} | $xml.Save("E:\test.xml")
I'm testing many others commands but i'm unsucessful :(
Can anyone give me some good tips in a way to solve my problem, it would be nice.
Regards,
Jf