I have an XML like this:
<Machines>
<Machine>
<Machine_Name>Mac Book Pro</Machine_Name>
<Machine_Type>Laptop</Machine_Type>
<Outputs>
<Output>
<Hour>1</Hour>
<Speed>Very Quick</Speed>
</Output>
<Output>
<Hour>2</Hour>
<Speed>Quick</Speed>
</Output>
</Outputs>
<Capacities>
<Capacity>
<Hour>1</Hour>
<Speed>50%</Speed>
</Capacity>
<Capacity>
<Hour>2</Hour>
<Speed>30%</Speed>
</Capacity>
</Capacities>
</Machine>
<Machine>
<Machine_Name>LG Desktops</Machine_Name>
<Machine_Type>Personal computers</Machine_Type>
<Outputs>
<Output>
<Hour>1</Hour>
<Speed>Fast</Speed>
</Output>
<Output>
<Hour>2</Hour>
<Speed>Moderate</Speed>
</Output>
</Outputs>
<Capacities>
<Capacity>
<Hour>1</Hour>
<Speed>30%</Speed>
</Capacity>
<Capacity>
<Hour>2</Hour>
<Speed>10%</Speed>
</Capacity>
</Capacities>
</Machine>
</Machines>
This is the regex i tried "<Capacity>(?<Value>[\d\w\s\W\D]*)<\/Capacity>"
但我得到的是位于第一次出现到最后一次出现之间的所有标签,我得到所有标签:输出,小时,速度,机器名称(我得到输出和容量的小时和速度)。从这个我想获取属于 (Capacities) 的标签 (Speed) 的值。也就是说,我需要测量特定机器类型每小时机器的速度能力,并将其与前一小时的速度进行比较,找出速度的增加或减少并相应地生成报告。
Can anyone please tell an accurate regex to fetch such data and I m strictly instructed to use regex to get these data I am not suppose to use XMLDocument so please kindly suggest me a regex i badly need it.