Click here to Skip to main content
15,919,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All

I have trouble with the logic that shows closest matches in xml file.

Scneraio:

I am accepts some values from the user and checking those values are matching in any xml nodes using xpath. If the node is math then fine, if not match we need to shows closes mathces based on matching parid of each node.

Here is my xml code, the code having hundresd of bod1, body2 nodes. User enter set of values that mathces any one of the body1 node. If there is no match then I need to shows body1, bode2 that are closest matches.

<Head>
<body1>
<node1>1</node1>
<node2>4</node2>
<node3>3</node3>
<node4>0</node4>
<node5>1,2,3,4,5,6,7,12</node5>
<node6>1,2,3,4</node6>
<node7>2</node7>
<node8></node8>
<node9></node9>
<node10>1,2,3,4</node10>
</body1>
<body2>
<node1>2</node1>
<node2>1</node2>
<node3>2</node3>
<node4>0</node4>
<node5>4,5,6,7,12</node5>
<node6>1,2,3,4</node6>
<node7>2</node7>
<node8></node8>
<node9></node9>
<node10>1,2,3,4</node10>
</body2>
<body3>
<node1>1</node1>
<node2>4</node2>
<node3>3</node3>
<node4>0</node4>
<node5>1,2,3,4,5,6,7,12</node5>
<node6>1,2,3,4</node6>
<node7>2</node7>
<node8></node8>
<node9></node9>
<node10>1,2,3,4</node10>
</body3>
<body4>
<node1>2</node1>
<node2>1</node2>
<node3>2</node3>
<node4>0</node4>
<node5>4,5,6,7,12</node5>
<node6>1,2,3,4</node6>
<node7>2</node7>
<node8></node8>
<node9></node9>
<node10>1,2,3,4</node10>
</body4>
</head>


Please suggest me.


Thanks in advance
Posted

1 solution

You have to define (is up to you) a measure of the difference between two sets of nodes. Then you have to minimize such a measure.
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900