Changing values in XML xpath
Posted: Thu Jan 17, 2019 9:24 am
Morning all,
I have been trying to use xpath in order for me to get values from the xml below. Is it actually possible to target multiple attribute values using xpath and then change these values without scripting?
So the values that i need are:
Where "/Root/Order_Info/ProductType/Products[@Type='Manual']" and "/Root/Order_Info/ProductType/Products/Components[@Type='Inset']" then
Select all "/Root/Order_Info/ProductType/Products/Components/[@PageCount]" and then add 16 to each PageCount.
If scripting is the only way then that is fine, but due to me being somewhat of a beginner and still getting to grips with scripting could someone give me a starting point? I have done very basic scripts but nothing like this.
Any info would be great.
Cheers
I have been trying to use xpath in order for me to get values from the xml below. Is it actually possible to target multiple attribute values using xpath and then change these values without scripting?
So the values that i need are:
Where "/Root/Order_Info/ProductType/Products[@Type='Manual']" and "/Root/Order_Info/ProductType/Products/Components[@Type='Inset']" then
Select all "/Root/Order_Info/ProductType/Products/Components/[@PageCount]" and then add 16 to each PageCount.
If scripting is the only way then that is fine, but due to me being somewhat of a beginner and still getting to grips with scripting could someone give me a starting point? I have done very basic scripts but nothing like this.
Any info would be great.
Cheers
Code: Select all
<?xml version="1.0"?>
<Root>
<OrderInfo ID="11111">
<ProductType ProductName="TEST1">
<Products ProductType="BOOK" Name="A" Type="Throwout">
<Components Filename="Test1_throwout.pdf" Type="Throwout" PageCount="4">
<ComponentSpecs SpecClass="" />
</Components>
<ProductSpecs SpecClass="" />
</Products>
<Products ProductType="BOOK" Name="B" Type="Manual">
<Components Filename="Test1_inset.pdf" Type="Inset" PageCount="200">
<ComponentSpecs SpecClass="" />
</Components>
<Components Filename="Test1_cover.pdf" Type="Cover" PageCount="4">
<ComponentSpecs SpecClass="" />
</Components>
<ProductSpecs SpecClass="" />
</Products>
<Products ProductType="BOOK" Name="C" Type="Folder">
<Components Filename="Folder.pdf" Type="Folder" PageCount="4">
<ComponentSpecs SpecClass="" />
</Components>
<ProductSpecs SpecClass="" />
</Products>
<CustomerProductSpecs SpecClass="" />
</ProductType>
<ProductType ProductName="TEST2">
<Products ProductType="CD" Name="A" Type="CD">
<Components Filename="CD.pdf" Type="CD" PageCount="">
<ComponentSpecs SpecClass="" />
</Components>
<ProductSpecs SpecClass="" />
</Products>
<CustomerProductSpecs SpecClass="" />
</ProductType>
<ProductType ProductName="TEST3">
<Products ProductType="BOOK" Name="A" Type="Throwout">
<Components Filename="Test1_throwout.pdf" Type="Throwout" PageCount="4">
<ComponentSpecs SpecClass="" />
</Components>
<ProductSpecs SpecClass="" />
</Products>
<Products ProductType="BOOK" Name="B" Type="Manual">
<Components Filename="Test1_inset.pdf" Type="Inset" PageCount="200">
<ComponentSpecs SpecClass="" />
</Components>
<Components Filename="Test1_cover.pdf" Type="Cover" PageCount="4">
<ComponentSpecs SpecClass="" />
</Components>
<ProductSpecs SpecClass="" />
</Products>
<Products ProductType="BOOK" Name="C" Type="Folder">
<Components Filename="Folder.pdf" Type="Folder" PageCount="4">
<ComponentSpecs SpecClass="" />
</Components>
<ProductSpecs SpecClass="" />
</Products>
<OrderInfoSpecs SpecClass="" />
</ProductType>
</OrderInfo>
</Root>