How to get the attribute value of an item of a string array?

My xml is like this:

<string-array name="persons_array">
        <item deptcode="11S01">person 1</item>
        <item deptcode="12S01">person 2</item>
        <item deptcode="20S01">person 3</item>
        <item deptcode="35S04">person N</item>

All I need is to get the deptcode and put it in an editbox.



try this:

DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource source = new InputSource();
source.setCharacterStream(new StringReader(xmlRecords));
Document doc = db.parse(source);
NodeList nodes = doc.getElementsByTagName("item");
for(int i = 0; i< nodes.getLength();i++)
   NamedNodeMap attr = nodes.item(i).getAttributes();
//Next string is your deptcode 
   String str = attr.getNamedItem("deptcode").getNodeValue();
   //Here you can set it to EditText

Need Your Help

Incorrect Regex.Split scan

.net regex

I'm having a problem with this expression: ;(?!.*(\}|""|')|(\{|""|')) and the problem is this:

Performance of HashSet<T> and Linq queries

c# performance linq-to-objects hashset

During last week I received some code and was asked to improve the performance. So started with the job, but soon I saw that they use a lot of HashSet&lt;T&gt; objects, to store big collections of

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.