Skip navigation
jscotti
Currently Being Moderated

get string from XML

Nov 17, 2011 8:20 AM

I have the following in an execute script. It creates an XML quite nicely. However, I need it to retrieve the data for comparison versus creating an XML. Is there an easy way to convert what I have so this can be accomplished? I need to compare the commonName to a string value that will be static, and store the userId that corresponds to it as a string. 

 

 

DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
DocumentBuilder bd = fact.newDocumentBuilder();
Document doc = bd.newDocument();
Element root = (Element) doc.createElement("users");
doc.appendChild(root);

if(userlist != null)
{
Iterator iterator = userlist.iterator();
while ( iterator.hasNext() )
{
  User eachUser = (User)iterator.next();

  Element UserNode = doc.createElement("user");

  Element ValueNode = doc.createElement("userID");
  ValueNode.appendChild(doc.createTextNode(eachUser.userId));
  UserNode.appendChild(ValueNode);

 

  Element ValueNode = doc.createElement("commonName");
  ValueNode.appendChild(doc.createTextNode(eachUser.commonName));
  UserNode.appendChild(ValueNode);

  root.appendChild(UserNode);
}
}
patExecContext.setProcessDataValue("/process_data/uXML", (Object)doc)

 
Replies
  • Currently Being Moderated
    Nov 18, 2011 9:04 AM   in reply to jscotti

    I am not sure I follow.

     

    The Execute Script service instance, above, creates the process variable "uXML" of type Object. Is the intent to iterate over "commonName" in "uXML" in a subsequent operation to determine the existence of the content of a second process variable containing the name?

     

    Steve

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points