convert list to charsequence

sir i have a list :that contain some value : after i am geeting node content value: and cheak that node content value contains list value or not:but i am getting exception because list not converted to charsequence : my code is List<String> xx = new ArrayList<String>(); xx.add("Van"); xx.add("Von"); xx.add("Le"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document d = builder.parse(file); d.getDocumentElement().normalize(); String[] s = xx.toArray(new String[xx.size()]); NodeList ndlist = d.getElementsByTagName("personName"); for (int i = 0; i < ndlist.getLength(); i++) { Node node = ndlist.item(i); NodeList nl = node.getChildNodes(); for (int j = 0; j < nl.getLength(); j++) { Node node1 = nl.item(j); if (node1.getNodeName().equals("givenNames")) { Element element = (Element) node1; String str = element.getTextContent().toUpperCase(); if(str.contains(xx))//error list cannot convert to charsequence { //some opration } } }
sanjeev kumarAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
... my code is ...
Post code in code tags please, and not in bold
0
sanjeev kumarAuthor Commented:
Thank u CEHJ
List<String> xx = new ArrayList<String>(); xx.add("Van"); xx.add("Von"); xx.add("Le"); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document d = builder.parse(file); d.getDocumentElement().normalize(); String[] s = xx.toArray(new String[xx.size()]); NodeList ndlist = d.getElementsByTagName("personName"); for (int i = 0; i < ndlist.getLength(); i++) { Node node = ndlist.item(i); NodeList nl = node.getChildNodes(); for (int j = 0; j < nl.getLength(); j++) { Node node1 = nl.item(j); if (node1.getNodeName().equals("givenNames")) { Element element = (Element) node1; String str = element.getTextContent().toUpperCase(); if(str.contains(xx))//error list cannot convert to charsequence { //some opration } } }

Open in new window

0
sanjeev kumarAuthor Commented:
List<String> xx = new ArrayList<String>();
 xx.add("Van"); 
xx.add("Von");
 xx.add("Le");
 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
 DocumentBuilder builder = factory.newDocumentBuilder();
 Document d = builder.parse(file); 
d.getDocumentElement().normalize(); 
String[] s = xx.toArray(new String[xx.size()]);//casting list to String
 NodeList ndlist = d.getElementsByTagName("personName");
 for (int i = 0; i < ndlist.getLength(); i++)
 { 
Node node = ndlist.item(i); 
NodeList nl = node.getChildNodes(); 
for (int j = 0; j < nl.getLength(); j++) 
{ 
Node node1 = nl.item(j);
 if (node1.getNodeName().equals("givenNames"))
 {
 Element element = (Element) node1;
 String str = element.getTextContent().toUpperCase(); 
if(str.contains(xx))//error list cannot convert to charsequence
 { 
//some opration
 } } }

Open in new window

0
CEHJCommented:
String[] s = xx.toArray(new String[xx.size()]);//casting list to String

Open in new window

That's unnecessary. You just need to iterate 'xx'

for (String s : xx) {
   if(str.contains(s.toUpperCase())) {
      // Do something
   }
}

Open in new window


Can you explain the presence of the question HERE?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sanjeev kumarAuthor Commented:
Thanks for your comment
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Node.js

From novice to tech pro — start learning today.