Creating XML file
static void Job66(Args _args)
{
CustTable custTable;
XmlTextWriter xmlTextWriter =XmlTextWriter::newFile("D:\\test.xml");
xmlTextWriter.writeStartDocument();
xmlTextWriter.writeStartElement("CustTable");
while select * from custTable
{
xmlTextWriter.writeStartElement("CustomerInfomration");
xmlTextWriter.writeAttributeString("AccountNum",custTable.AccountNum);
xmlTextWriter.writeElementString("Name",custTable.name());
xmlTextWriter.writeElementString("Address",custTable.address());
xmlTextWriter.writeElementString("Phone",custTable.phone());
xmlTextWriter.writeEndElement();
}
xmlTextWriter.writeEndElement();
xmlTextWriter.writeEndDocument();
info("XML is created");
}
Readubg XML File
static void Job67(Args _args)
{
XmlTextReader reader = XmlTextReader::newFile("D:\\Test.xml");
XmlNode node;
XmlElement element;
XmlNodeList nodeList,nodeList2;
XmlNamedNodeMap xmlNamedNodeMap;
XmlDocument doc = XmlDocument::newFile("D:\\Test.xml");
element = doc.getNamedElement("CustTable");
nodelist = element.childnodes();
node = nodelist.nextnode();
while(node)
{
//info(node.name());
xmlNamedNodeMap = node.attributes();
nodeList2 = node.childNodes();
node = nodeList2.nextNode();
while(node)
{
info(strFmt("%1:%2",node.name(),node.text()));
node = nodeList2.nextNode();
}
node =xmlNamedNodeMap.getNamedItem("AccountNum");
info(strFmt("%1 : %2",node.name(),node.value()));
//info(node.name());
node = nodelist.nextnode();
}
}
No comments:
Post a Comment