C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » XML »

Getting node values by passing two parameters to the xml document


Posted Date: 30 Sep 2009      Posted By: Ganesh Gurram      Member Level: Bronze     Points: 1   Responses: 3



Hi

Below is the xml content having market values 1 and 2. i have the code for getting code(ABC) by passing the market value 1.
(EX: "//City[Market ='1']/Code"

now i want to pass values 1 and 2 to get the codevalues "ABC and BBC". can you please help me in getting this done.

<City>
<Code>ABC</Code>
<Name>GANESH KUMAR</Name>
<Market>1</Market>
<IsHACity>1</IsHACity>
<IsAltCity>0</IsAltCity>
<SortOrder>1</SortOrder>
<ShowAvailMsg>0</ShowAvailMsg>
<CityGroupID>0</CityGroupID>
<CityGroup>INDIA</CityGroup>
<Active>1</Active>
</City>


<City>
<Code>BBC</Code>
<Name>BIG MAN</Name>
<Market>2</Market>
<IsHACity>1</IsHACity>
<IsAltCity>0</IsAltCity>
<SortOrder>2</SortOrder>
<ShowAvailMsg>0</ShowAvailMsg>
<CityGroupID>0</CityGroupID>
<CityGroup>BIG ISLAND</CityGroup>
<Active>1</Active>
</City>



Regards,
Ganesh





Responses

Author: Kunal    30 Sep 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

define a method which take two args (1 nad 2 )
in that method call the method that u r using for single call 2 times and get the results to use

public string GetBoth(int code1, int code2)
{
StringBuilder str=new StringBuilder ();
str.Append(call method with "//City[Code =code1]/Market");
str.Append(" and ");

str.Append(call method with "//City[Code =code2]/Market");
return str.ToString();
}

Happy Programming
Kunal
Don't forget to rate the response...



Author: Rajeswari    30 Sep 2009Member Level: GoldRating: 3 out of 53 out of 53 out of 5     Points: 3

First you can get whole City tag using xpath query...
they enumerate the recored and compare and get back the result



Author: Chandra Shekar.Y    15 Oct 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Hi

Generate an xpath with the parameters you pass seperated by or and use SelectNodes which returns the Code nodes from the city.

eg: //City[Market = '1' or Market='2']/Code

Or

string.Format("//City[Market='{0}' or Market='{2}']/Code", variable1, variable2)

here variable1 contains value 1 and variable2 contains value 2.

Hope this helps you.



Post Reply
You must Sign In to post a response.
Next : Sort date using .xsl
Previous : Xslt tool
Return to Discussion Forum
Post New Message
Category: XML

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use