Writing and Reading to a XML File

Writing to a XML File

static void writeXML(Args _args)

{

XMLTextWriter xw; FileDemo ct;

;

xw = XMLTextWriter::newFile(“c:\FileDemo.xml”);

xw.writeStartDocument();

xw.writeStartElement(“Details”);

while select ct

{

xw.writeStartElement(“CustomerDetails”);

xw.writeElementString(“Id”,ct.Id);

xw.writeElementString(“Name”,ct.Name);

xw.writeEndElement();

}

xw.writeEndElement();

xw.writeEndDocument();

xw.close();

}

Reading from a XML File

static void readingXML(Args _args)

{

XMLDocument xmlDoc = XMLDocument::newFile(“c:\FileDemo.xml”);

int i, nooftags;

;

nooftags = xmlDoc.getElementsByTagName(“CustomerDetails”).length();

for(i=0; i<nooftags; i++)

{

info(strfmt(“%1″, xmlDoc.getElementsByTagName(“Id”).item(i).text()));

info(strfmt(“%1″, xmlDoc.getElementsByTagName(“Name”).item(i).text()));

}

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: