Search XML

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Trevor

    #1

    Search XML

    I want to search through my xml and mark the amount of time I find the
    necessary string values in the parent and if the parent has more than 4
    matches I want to write out those parents and there child elements to
    another xml file but I have no idea where to start.

    eg xml
    <Root>
    <ItemA1>
    <LineNo>A1</LineNo>
    <First>1</First>
    <Second>2</Second>
    <Third>3</Third>
    <Fourth>4</Fourth>
    <Fifth>5</Fifth>
    <Sixth>6</Sixth>
    </ItemA1>
    <ItemA2>
    <LineNo>A2</LineNo>
    <First>7</First>
    <Second>8</Second>
    <Third>9</Third>
    <Fourth>10</Fourth>
    <Fifth>11</Fifth>
    <Sixth>12</Sixth>
    </ItemA2>
    <ItemA3>
    <LineNo>A3</LineNo>
    <First>3</First>
    <Second>14</Second>
    <Third>15</Third>
    <Fourth>2</Fourth>
    <Fifth>5</Fifth>
    <Sixth>1</Sixth>
    </ItemA3>
    </Root>

    If I search for the values 1, 2, 3, 4, 5, 6 then I want to say that
    <ItemA1and <ItemA3have 4 or more matches and they must be written
    out to another xml file.
    I was thinking about maybe adding to the parent node <ItemA1and
    attribute that could increment everytime there was a matching value
    found so that when I needed to write out the new xml file I could only
    write out the parent nodes where the attribute is greater than
    4.....just a though.
    Please could someone help me on this.......a little bit of code would
    help as well to give me an idea of how to achieve this.......beca use I
    have tried searching for something that would give me some direction
    but I have not found much that would help me specifically.

Working...