I have a String that contains XML nodes in it, and I'm trying to use DOM parsing to process this string to extract node values and store them in local variables.
XML stored in String variable:
<carGarage>
<car>
<make>Chrysler</make>
<color>Red</color>
</car>
<car>
<make>Musano</make>
<color>Blue</color>
</car>
</carGarage>
My Java class is where I want to extract XML values and store them in local attributes:
public class CarGarage
{ String make, color;
public void setMake(String make)
{ this.make = make; }
public void setColor(String color)
{ this.color = color; }
public void DOMparsingMethod(Node thisNode)
{ int typeOfNode = thisNode.getNodeType();
...
}
}
What is the best way to approach this? I looked at StringBufferInputStream, but this is deprecated. I really got lost.
Thankyou, Lucas.
source
share