How to write a string into an XML
I wrote a web service to receive a string and write to Oracle Application Server as XML Document. But It is not writing anything. Below is writer program. What do I need to add to make it work
public class Writer
public Writer()
} public void WriteHabFile(String out, String fileName)
XMLDocument doc = new XMLDocument();
try
XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName)));
output.setEncoding("utf-8");
output.printDocument(doc);
output.close();
catch (Exception e)
System.out.println(e.toString());
public void WriteLanFile(String out2, String fileName2)
XMLDocument doc = new XMLDocument();
try
XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName2)));
output.setEncoding("utf-8");
output.printDocument(doc);
output.close();
catch (Exception e)
System.out.println(e.toString());
Any help would be greatly appreciated.
Why don't you try something like:
public class Writer {
public Writer(){}
public void WriteHabFile(String out, String fileName) {
oracle.xml.parser.v2.DOMParser parser = new oracle.xml.parser.v2.DOMParser();
try {
parser.parse(new BufferedReader(new StringReader(out)));
catch(XMLParseException xe) {
// Do Something
catch(SAXException se) {
// Do Something
catch(IOException ie) {
// Do Something
XMLDocument doc = parser.getDocument();
try {
XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName)));
output.setEncoding("utf-8");
output.printDocument(doc);
output.close();
catch (Exception e)
System.out.println(e.toString());
public void WriteLanFile(String out2, String fileName2) {
oracle.xml.parser.v2.DOMParser parser = new oracle.xml.parser.v2.DOMParser();
try {
parser.parse(new BufferedReader(new StringReader(out)));
catch(XMLParseException xe) {
// Do Something
catch(SAXException se) {
// Do Something
catch(IOException ie) {
// Do Something
XMLDocument doc = parser.getDocument();
try {
XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName2)));
output.setEncoding("utf-8");
output.printDocument(doc);
output.close();
catch (Exception e)
System.out.println(e.toString());
Hope this helps,
Mark Brown
Similar Messages
-
How to Parse a string into an XML DOM ?
Hi,
I want to parse a String into an XML DOM. Not able to locate any parser which supports that. Any pointers to this?Download Xerces from xml.apache.org. Place the relevant JAR's on your classpath. Here is sample code to get a DOM document reference.
- Saish
public final class DomParser extends Object {
// Class Variables //
private static final DocumentBuilder builder;
private static final String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
/** W3C schema definitions */
private static final String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
// Constructors //
static {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
builder = factory.newDocumentBuilder();
builder.setErrorHandler(new ErrorHandler() {
public void warning(SAXParseException e) throws SAXException {
System.err.println("[warning] "+e.getMessage());
public void error(SAXParseException e) throws SAXException {
System.err.println("[error] "+e.getMessage());
public void fatalError(SAXParseException e) throws SAXException {
System.err.println("[fatal error] "+e.getMessage());
throw new XmlParsingError("Fatal validation error", e);
catch (ParserConfigurationException fatal) {
throw new ConfigurationError("Unable to create XML DOM document parser", fatal);
catch (FactoryConfigurationError fatal) {
throw new ConfigurationError("Unable to create XML DOM document factory", fatal);
private DomParser() {
super();
// Public Methods //
public static final Document newDocument() {
return builder.newDocument();
public static final Document parseDocument(final InputStream in) {
try {
return builder.parse(in);
catch (SAXException e) {
throw new XmlParsingError("SAX exception during parsing. Document is not well-formed or contains " +
"illegal characters", e);
catch (IOException e) {
throw new XmlParsingError("Encountered I/O exception during parsing", e);
}- Saish -
How to write input data into an xml file
Hi All,
I have some input data and i have to write it
into an xml file.How is it possible send me some related
links regarding this and source code if any.Hi
Try to go through these links.I hope this will help you to solve your problem.
http://www.xml.com/pub/a/2003/07/09/udell.html
Thanks
Mrutyunjaya Tripathy -
How to write a string into a file in java
Say i hv a string named str.......plz give the total code of creating a file and writing the string into it
This is the function where i am trying to write a file....i hv highlighted the regions where file writing codes are used........kindly suggest where is my mistake as this code is running but not writing anything.........only the file is getting created but nothing is getting written...aslo i havnt put fw.close() here where in the code should I put it
static void func1(String str) throws IOException
int i=0,j=0,k=1,m=0;
int size1=0,file_size=0;
String str1;
int arr[]= new int[no_of_lines+1];
FileWriter fw;
*try{*
fw=new FileWriter("output.txt");
catch(IOException exc)
System.out.println("Cannot open file");
return;
arr[0]=0;
while(true)
a=svcRand.nextInt(10);
k++;
i=0;
j++;
try{
FileReader fr= new FileReader(str);
BufferedReader br= new BufferedReader(fr);
while((str1=br.readLine()) !=null)
i++;
if(i==a)
file_size=func2(str1,size1);
str1=str1+"\r\n";
fw.write(str1);
catch(FileNotFoundException exc)
System.out.println("File not found");
return;
catch(ArrayIndexOutOfBoundsException exc)
System.out.println("Usage: Showfile file");
return; -
How to write a string as an XML Document
I wrote a web service to receieve a string and then write as an XMl document . But In my writer.java program, I am not doing something right. Please let me know what I am doing wrong.
Below is writer program:
public class Writer
public Writer()
} public void WriteHabFile(String out, String fileName)
XMLDocument doc = new XMLDocument();
try
XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName)));
output.setEncoding("utf-8");
output.printDocument(doc);
output.close();
catch (Exception e)
System.out.println(e.toString());
public void WriteLanFile(String out2, String fileName2)
XMLDocument doc = new XMLDocument();
try
XMLPrintDriver output=new XMLPrintDriver(new FileOutputStream(new File(fileName2)));
output.setEncoding("utf-8");
output.printDocument(doc);
output.close();
catch (Exception e)
System.out.println(e.toString());
}The problems is that your XML document is not parsed.
-
How to convert Java string into XML one?
With SAX I can parse an xml file, but I should create xml file by hands.
Ok, it's simple, but how to encode java string into XML constant
like "Hello & goodby" into "Hello & goodby" ?
Is there a standard method for such special xml characters?If you are creating your XML "by hand" then just make sure your hands know that you have to do that. It isn't difficult to write a Java method to do it, if "by hand" means "in Java code". Otherwise your XML is not well-formed. And as far as I know there is no package that takes ill-formed XML and fixes it up.
-
How to read and write a string into a txt.file
Hi, I am now using BEA Workshop for Weblogic Platform version10. I am using J2EE is my programming language. The problem I encounter is as the above title; how to read and write a string into a txt.file with a specific root directory? Do you have any sample codes to reference?
I hope someone can answer my question as soon as possible
Thank you very much.Accessing the file system directly from a web app is a bad idea for several reasons. See http://weblogs.java.net/blog/simongbrown/archive/2003/10/file_access_in.html for a great discussion of the topic.
On Weblogic there seems to be two ways to access files. First, use a File T3 connector from the console. Second, use java.net.URL with the file: protocol. The T3File object has been deprecated and suggests:
Deprecated in WebLogic Server 6.1. Use java.net.URL.openConnection() instead.
Edited by: m0smith on Mar 12, 2008 5:18 PM -
How can i write a string into a specified pos of a file?
How can i write a string into a specified pos of a file without read all file into ram and write the whole file again?
for example:
the content of file is:
name=123
state=456
i want to modify the value of name with 789
(write to file without read all file into ram)
How can i do it? thank youtake this as an idea. it actually does what i decribed above. you sure need to make some modifications so it works for your special need. If you use it and add any valuable code to it or find any bugs, please let me know.
import java.io.*;
import java.util.*;
* Copyright (c) 2002 Frank Fischer <[email protected]>
* All rights reserved. See the LICENSE for usage conditions
* ObjectProperties.java
* version 1.0, 2002-09-12
* author Frank Fischer <[email protected]>
public class ObjectProperties
// the seperator between the param-name and the value in the prooperties file
private static final String separator = "=";
// the vector where we put the arrays in
private Vector PropertiesSet;
// the array where we put the param/value pairs in
private String propvaluepair[][];
// the name of the object the properties file is for
public String ObjectPropertiesFileName;
// the path to the object'a properties file
public String ObjectPropertiesDir;
// reference to the properties file
public File PropertiesFile;
// sign for linebreak - depends on platforms
public static final String newline = System.getProperty("line.separator");
public ObjectProperties(String ObjectPropertiesFileName, String ObjectPropertiesDir, ObjectPropertiesManager ObjectPropertiesManager)
// System.out.println("Properties Objekt wird erzeugt: "+ObjectPropertiesFileName);
this.ObjectPropertiesFileName = ObjectPropertiesFileName;
this.ObjectPropertiesDir = ObjectPropertiesDir;
// reference to the properties file
PropertiesFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
// vector to put the param/value pair-array in
PropertiesSet = new Vector();
// System.out.println("Properties File Backup wird erzeugt: "+name);
backup();
// System.out.println("Properties File wird eingelesen: "+PropertiesFile);
try
//opening stream to file for read operations
FileInputStream FileInput = new FileInputStream(PropertiesFile);
DataInputStream DataInput = new DataInputStream(FileInput);
String line = "";
//reading line after line of the properties file
while ((line = DataInput.readLine()) != null)
//just making sure there are no whitespaces at the beginng or end of the line
line = cutSpaces(line);
if (line.length() > 0)
//$ indicates a param-name
if (line.startsWith("$"))
// array to store a param/value pair in
propvaluepair = new String[1][2];
//get the param-name
String parameter = line.substring(1, line.indexOf(separator)-1);
//just making sure there are no whitespaces at the beginng or end of the variable
parameter = cutSpaces(parameter);
//get the value
String value = line.substring(line.indexOf(separator)+1, line.length());
//just making sure there are no whitespaces at the beginng or end of the variable
value = cutSpaces(value);
//put the param-name and the value into an array
propvaluepair[0][0] = parameter;
propvaluepair[0][1] = value;
// System.out.println("["+ObjectPropertiesFileName+"] key/value gefunden:"+parameter+";"+value);
//and finaly put the array into the vector
PropertiesSet.addElement(propvaluepair);
// error handlig
catch (IOException e)
System.out.println("ERROR occured while reading property file for: "+ObjectPropertiesFileName);
System.out.println("ERROR CODE: "+e);
// System.out.println("in ObjectProperties");
// function to be called to get the value of a specific paramater 'param'
// if the specific paramater is not found '-1' is returned to indicate that case
public String getParam(String param)
// the return value indicating that the param we are searching for is not found
String v = "-1";
// looking up the whole Vector
for (int i=0; i<PropertiesSet.size(); i++)
//the String i want to read the values in again
String s[][] = new String[1][2];
// trying to get out the array from the vector again
s = (String[][]) PropertiesSet.elementAt(i);
// comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
if (s[0][0].equals(param) == true)
//if the param-names are the same, we look up the value and write it in the return variable
v = s[0][1];
// making sure the for loop ends
i = PropertiesSet.size();
// giving the value back to the calling procedure
return v;
// function to be called to set the value of a specific paramater 'param'
public void setParam(String param, String value)
// looking up the whole Vector for the specific param if existing or not
for (int i=0; i<PropertiesSet.size(); i++)
//the String i want to read the values in again
String s[][] = (String[][]) PropertiesSet.elementAt(i);
// comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
if (s[0][0].equals(param) == true)
//if the param-names are the same, we remove the param/value pair so we can add the new pair later in
PropertiesSet.removeElementAt(i);
// making sure the for loop ends
i = PropertiesSet.size();
// if we land here, there is no such param in the Vector, either there was none form the beginng
// or there was one but we took it out.
// create a string array to place the param/value pair in
String n[][] = new String[1][2];
// add the param/value par
n[0][0] = param;
n[0][1] = value;
// add the string array to the vector
PropertiesSet.addElement(n);
// function to save all data in the Vector to the properties file
// must be done because properties might be changing while runtime
// and changes are just hold in memory while runntime
public void store()
backup();
String outtofile = "# file created/modified on "+createDate("-")+" "+createTime("-")+newline+newline;
try
//opening stream to file for write operations
FileOutputStream PropertiesFileOuput = new FileOutputStream(PropertiesFile);
DataOutputStream PropertiesDataOutput = new DataOutputStream(PropertiesFileOuput);
// looping over all param/value pairs in the vector
for (int i=0; i<PropertiesSet.size(); i++)
//the String i want to read the values in
String s[][] = new String[1][2];
// trying to get out the array from the vector again
s = (String[][]) PropertiesSet.elementAt(i);
String param = "$"+s[0][0];
String value = s[0][1];
outtofile += param+" = "+value+newline;
outtofile += newline+"#end of file"+newline;
try
PropertiesDataOutput.writeBytes(outtofile);
catch (IOException e)
System.out.println("ERROR while writing to Properties File: "+e);
catch (IOException e)
System.out.println("ERROR occured while writing to the property file for: "+ObjectPropertiesFileName);
System.out.println("ERROR CODE: "+e);
// sometimes before overwritting old value it's a good idea to backup old values
public void backup()
try
// reference to the original properties file
File OriginalFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
File BackupFile = new File(ObjectPropertiesDir+"/backup/"+ObjectPropertiesFileName+".backup");
//opening stream to original file for read operations
FileInputStream OriginalFileInput = new FileInputStream(OriginalFile);
DataInputStream OriginalFileDataInput = new DataInputStream(OriginalFileInput);
//opening stream to backup file for write operations
FileOutputStream BackupFileOutput = new FileOutputStream(BackupFile);
DataOutputStream BackupFileDataOutput = new DataOutputStream(BackupFileOutput);
// String content = "";
String line = "";
// do till end of file
while ((line = OriginalFileDataInput.readLine()) != null)
BackupFileDataOutput.writeBytes(line+newline);
// error handlig
catch (IOException e)
System.out.println("ERROR occured while back up for property file: "+ObjectPropertiesFileName);
System.out.println("ERROR CODE: "+e);
System.out.println("this is a serious error - the server must be stopped");
private String cutSpaces(String s)
while (s.startsWith(" "))
s = s.substring(1, s.length());
while (s.endsWith(" "))
s = s.substring(0, s.length()-1);
return s;
public String createDate(String seperator)
Date datum = new Date();
String currentdatum = new String();
int year, month, date;
year = datum.getYear()+1900;
month = datum.getMonth()+1;
date = datum.getDate();
currentdatum = ""+year+seperator;
if (month < 10)
currentdatum = currentdatum+"0"+month+seperator;
else
currentdatum = currentdatum+month+seperator;
if (date < 10)
currentdatum = currentdatum+"0"+date;
else
currentdatum = currentdatum+date;
return currentdatum;
public String createTime(String seperator)
Date time = new Date();
String currenttime = new String();
int hours, minutes, seconds;
hours = time.getHours();
minutes = time.getMinutes();
seconds = time.getSeconds();
if (hours < 10)
currenttime = currenttime+"0"+hours+seperator;
else
currenttime = currenttime+hours+seperator;
if (minutes < 10)
currenttime = currenttime+"0"+minutes+seperator;
else
currenttime = currenttime+minutes+seperator;
if (seconds < 10)
currenttime = currenttime+"0"+seconds;
else
currenttime = currenttime+seconds;
return currenttime; -
How to write the nodevalue back to xml file?
Hi, Everybody:
These are two packages I used. javax.xml.parsers.*,org.w3c.dom.*
Now I use "setNodeValue("abc") to set the node value to "abc". But it is not really saved back into XML file. It only change the node value in memory.
How to write the changes back to XML file? Thank you very much for your help.
Michelle* Version : 1.00
* File Purpose : Given the xml file loads into dom and recreate the file with the updated values.
* Developer : Kashif Qasim : 25/july/04
* Modify detail :
import java.lang.*;
import java.io.*;
import java.util.*;
import java.text.*;
import org.w3c.dom.*;
import org.apache.xerces.parsers.DOMParser;
import org.apache.xerces.*;
public class XMLWriter
private String displayStrings[] = new String[5000];
private int numberDisplayLines = 0;
private Document document;
//private final Node c;
public synchronized void displayDocument(String uri,Vector UpdatedValues,String getTaskID)
try {
DOMParser parser = new DOMParser();
parser.parse(uri);
document = parser.getDocument();
display(document, "",UpdatedValues);
} catch (Exception e) {
e.printStackTrace(System.err);
ReadXmlConfig objReadXmlConfig = null;
FileWriter filewriter = null;
try {
filewriter = new FileWriter(uri);
for(int loopIndex = 0; loopIndex < numberDisplayLines; loopIndex++){
filewriter.write(displayStrings[loopIndex].toCharArray());
//System.out.println("displayStrings[loopIndex].toCharArray() "+displayStrings[loopIndex].toString());
//filewriter.write("\n");
filewriter.close();
System.gc();
objReadXmlConfig = new ReadXmlConfig();
objReadXmlConfig.ITSLog("File updated for "+getTaskID+" succesfully, file is closed now ");
} catch (IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
objReadXmlConfig = new ReadXmlConfig();
objReadXmlConfig.ITSErrorLog("File updated FAILED for "+getTaskID+". Reason for file error "+e.toString());
}finally {
if (filewriter != null) {
System.out.println("Closing File");
objReadXmlConfig =null;
try{
filewriter.close();
}catch(IOException e){
System.err.println("Caught IOException: " + e.getMessage());
} else {
System.out.println("File not open");
private void display(Node node, String indent, Vector UpdtRecs)
if (node == null) {
return;
int type = node.getNodeType();
NodeList nodeList = document.getElementsByTagName("QueryParm");
int TotalRecs = UpdtRecs.size();
switch (type) {
case Node.DOCUMENT_NODE: {
displayStrings[numberDisplayLines] = indent;
displayStrings[numberDisplayLines] +=
"<?xml version=\"1.0\" encoding=\""+
"UTF-8" + "\"?>";
numberDisplayLines++;
displayStrings[numberDisplayLines] += "\n";
display(((Document)node).getDocumentElement(), "",UpdtRecs);
break;
case Node.ELEMENT_NODE: {
if(node.getNodeName().equals("QueryParm")) {
for(int i =0 ; i< nodeList.getLength() ; i++)
Node nodeQry = nodeList.item(i);
NamedNodeMap nnp = nodeQry.getAttributes();
for(int j= 0 ; j < nnp.getLength() ; j++)
Attr atr = (Attr) nnp.item(j);
if(atr.getName().equalsIgnoreCase("value_"+(i+1)))
//System.out.println(atr.getName() +" : " + atr.getNodeValue() );
atr.setNodeValue(UpdtRecs.get(i).toString());
displayStrings[numberDisplayLines] = indent;
displayStrings[numberDisplayLines] += "<";
displayStrings[numberDisplayLines] += node.getNodeName();
int length = (node.getAttributes() != null) ?
node.getAttributes().getLength() : 0;
Attr attributes[] = new Attr[length];
for (int loopIndex = 0; loopIndex < length; loopIndex++) {
attributes[loopIndex] = (Attr)node.getAttributes().item(loopIndex);
for (int loopIndex = 0; loopIndex < attributes.length; loopIndex++) {
Attr attribute = attributes[loopIndex];
displayStrings[numberDisplayLines] += " ";
displayStrings[numberDisplayLines] += attribute.getNodeName();
displayStrings[numberDisplayLines] += "=\"";
displayStrings[numberDisplayLines] += attribute.getNodeValue();
displayStrings[numberDisplayLines] += "\"";
displayStrings[numberDisplayLines]+=">";
numberDisplayLines++;
NodeList childNodes = node.getChildNodes();
if (childNodes != null) {
length = childNodes.getLength();
indent += " ";
for (int loopIndex = 0; loopIndex < length; loopIndex++ ) {
display(childNodes.item(loopIndex), indent,UpdtRecs);
break;
case Node.CDATA_SECTION_NODE: {
displayStrings[numberDisplayLines] = "";
displayStrings[numberDisplayLines] += "<![CDATA[";
displayStrings[numberDisplayLines] += node.getNodeValue();
displayStrings[numberDisplayLines] += "]]>";
numberDisplayLines++;
break;
case Node.TEXT_NODE: {
displayStrings[numberDisplayLines] = "";
String newText = node.getNodeValue().trim();
if(newText.indexOf("\n") < 0 && newText.length() > 0) {
displayStrings[numberDisplayLines] += newText;
displayStrings[numberDisplayLines] += "\n";
numberDisplayLines++;
break;
case Node.PROCESSING_INSTRUCTION_NODE: {
displayStrings[numberDisplayLines] = "";
displayStrings[numberDisplayLines] += "<?";
displayStrings[numberDisplayLines] += node.getNodeName();
String text = node.getNodeValue();
if (text != null && text.length() > 0) {
displayStrings[numberDisplayLines] += text;
displayStrings[numberDisplayLines] += "?>";
displayStrings[numberDisplayLines] += "\n";
numberDisplayLines++;
break;
if (type == Node.ELEMENT_NODE) {
displayStrings[numberDisplayLines] = indent.substring(0,
indent.length() - 4);
displayStrings[numberDisplayLines] += "</";
displayStrings[numberDisplayLines] += node.getNodeName();
displayStrings[numberDisplayLines] += ">";
displayStrings[numberDisplayLines] += "\n";
numberDisplayLines++;
indent += " ";
public static void main(String args[])
Vector xmlValue = new Vector();
xmlValue.add(0,"Kashif");
xmlValue.add(1,"Qasim");
//displayDocument("NewMediation.xml",xmlValue);
<?xml version="1.0" encoding="UTF-8"?>
<Mediation>
<Task1>
<Source>
<SourceDriver>com.microsoft.jdbc.sqlserver.SQLServerDriver</SourceDriver>
<SourceConnection>jdbc:microsoft:sqlserver://10.2.1.58:1433;DatabaseName=MTCVB_HDS;</SourceConnection>
<SourceUser>sa</SourceUser>
<SourcePassword>sa</SourcePassword>
<Table>
<SourceTable>t_Agent</SourceTable>
<SourceQuery><![CDATA[SELECT SkillTargetID,PersonID,PeripheralID,EnterpriseName,PeripheralNumber,Deleted,TemporaryAgent,AgentStateTrace,ChangeStamp FROM t_Agent where SkillTargetID > {value_1} order by SkillTargetID]]>
</SourceQuery>
<SourceParm BusinessRule="" ColumnName="SKILLTARGETID" ColumnNumber="1" DataType="Numeric" DefaultValue="0" Format="mm/dd/yyyy xx:xx:xx XX">
</SourceParm>
<SourceParm BusinessRule="" ColumnName="PERSONID" ColumnNumber="2" DataType="String" DefaultValue="" Format="">
</SourceParm>
<SourceParm BusinessRule="" ColumnName="PERIPHERALID" ColumnNumber="3" DataType="String" DefaultValue="" Format="">
</SourceParm>
<SourceParm BusinessRule="" ColumnName="ENTERPRISENAME" ColumnNumber="4" DataType="String" DefaultValue="" Format="">
</SourceParm>
<SourceParm BusinessRule="" ColumnName="PERIPHERALNUMBER" ColumnNumber="5" DataType="String" DefaultValue="" Format="">
</SourceParm>
<SourceParm BusinessRule="" ColumnName="DELETED" ColumnNumber="6" DataType="String" DefaultValue="" Format="">
</SourceParm>
<SourceParm BusinessRule="" ColumnName="TEMPORARYAGENT" ColumnNumber="7" DataType="String" DefaultValue="" Format="">
</SourceParm>
<SourceParm BusinessRule="" ColumnName="AGENTSTATETRACE" ColumnNumber="8" DataType="String" DefaultValue="" Format="">
</SourceParm>
<SourceParm BusinessRule="" ColumnName="CHANGESTAMP" ColumnNumber="9" DataType="String" DefaultValue="" Format="">
</SourceParm>
<QueryParm FldName_1="SkillTargetID" FldType_1="Number" value_1="0">
</QueryParm>
</Table>
</Source>
</Task1>
</Mediation>
The QueryParm values are updated thru this code :)
Hope it helps u ... -
A class to format an XML string into indented xml code
I am looking for a class or a piece of code to format an XML string into indented xml code
for example: an XML string as follows
<servlet><servlet-name>Login</servlet-name>servlet-class>ucs.merch.client.system.LoginServlet</servlet-class></servlet><servlet-mapping><servlet-name>Login</servlet-name>
to format into :
<servlet>
<servlet-name>Login</servlet-name>
<servlet-class>ucs.merch.client.system.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Login</servlet-name>
<url-pattern>/Login</url-pattern>
</servlet-mapping>
e-mail : [email protected]Xerces has a class called OutputFormat
If you have your XML document in memory, you can format it using the method setIndenting(true) on the OutputFormat class. The following is an example:
assuming xmlDoc is our document and fileName is the name of the file we wish to write to:
OutputFormat format = new OutputFormat(xmlDoc);
// setup output file name
PrintWriter printwriter = new PrintWriter(new FileWriter(fileName, false));
// construct an XMLSerializer for writing the document
XMLSerializer serializer = new XMLSerializer( printwriter, format );
// Ensure output is indented correctly...
format.setIndenting(true);
// set serializer as a DOM Serializer
serializer.asDOMSerializer();
// serialize the document
serializer.serialize(xmlDoc);
hope this helps!
Rob. -
How to write the oracle data as XML format. (.XML file)
create or replace procedure pro(p_number )
is
cursor c1 is select *from emp where empno=p_number;
v_file utl_file.file_type;
begin
v_file := utl_file.fopen('dirc','filename.txt','w');
for i in c1 loop
utl_file.put_line(v_file,i.ename || i.empno ||i.job);
end loop;
closef(v_file);
end;
Now my client want instead of .txt file he need .xml files
File should contains xml tags. can any one help regarding this.. with one example.
How to write the oracle data as XML format. (.XML file)hi,
hope this example will do something....
SQL> select employee_id, first_name, last_name, phone_number
2 from employees where rownum < 6
EMPLOYEE_ID FIRST_NAME LAST_NAME PHONE_NUMBER
100 Steven King 515.123.4567
101 Neena Kochhar 515.123.4568
102 Lex De Haan 515.123.4569
103 Alexander Hunold 590.423.4567
104 Bruce Ernst 590.423.4568
SQL> select dbms_xmlgen.getxml('select employee_id, first_name,
2 last_name, phone_number from employees where rownum < 6') xml
3 from dual;
*<?xml version="1.0"?>*
*<ROWSET>*
*<ROW>*
*<EMPLOYEE_ID>100</EMPLOYEE_ID>*
*<FIRST_NAME>Steven</FIRST_NAME>*
*<LAST_NAME>King</LAST_NAME>*
*<PHONE_NUMBER>515.123.4567</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>101</EMPLOYEE_ID>*
*<FIRST_NAME>Neena</FIRST_NAME>*
*<LAST_NAME>Kochhar</LAST_NAME>*
*<PHONE_NUMBER>515.123.4568</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>102</EMPLOYEE_ID>*
*<FIRST_NAME>Lex</FIRST_NAME>*
*<LAST_NAME>De Haan</LAST_NAME>*
*<PHONE_NUMBER>515.123.4569</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>103</EMPLOYEE_ID>*
*<FIRST_NAME>Alexander</FIRST_NAME>*
*<LAST_NAME>Hunold</LAST_NAME>*
*<PHONE_NUMBER>590.423.4567</PHONE_NUMBER>*
*</ROW>*
*<ROW>*
*<EMPLOYEE_ID>104</EMPLOYEE_ID>*
*<FIRST_NAME>Bruce</FIRST_NAME>*
*<LAST_NAME>Ernst</LAST_NAME>*
*<PHONE_NUMBER>590.423.4568</PHONE_NUMBER>*
*</ROW>*
*</ROWSET>*
ask if you want more assistance.
thanks. -
How to convert HL7 file into an XML
Hi All,
I am new to HL7,can any one tell how to convert HL7 file into an XML.Give sample demo or related links.
My sample HL7 file is as follows how can I convert.
FHS|^~\&||Tax ID123^Lab Name123^L|||201110191435||HL7.txt||1234567|123||
PID|seqno|123||john^chambers^^Dr^Dr|2456 california ave^San jose^CA^85254|19601212|M
FHS|^~\&||Tax ID123^Lab Name123^L|||File Creaqted Date|File Security|FileName||File HeaderComment||Facility|FileCreatedDateTime|File Security|File Name|File Header Comment|FileControlId|Reference File Control ID|
PID|seqno|patientId||LastName^FirstName^MiddleName^Title^Degree|Street^City^State^zip|patientDOB|gender
<Report>
<FileHeader>
<FileSendingApplication> </FileSendingApplication>
<TaxID>Tax ID123</TaxID>
<LabName>Lab Name123</LabName>
<FileSendngFacilityType>L</FileSendngFacilityType>
<FileReceivingApplication></FileReceivingApplication>
<FileReceivingFacility></FileReceivingFacility>
<FileCreatedDateTime>201110191435</FileCreatedDateTime>
<FileSecurity></FileSecurity>
<FileName>HL7.txt</FileName>
<FileHeaderComment></FileHeaderComment>
<FileControlId>1234567</FileControlId>
<ReferenceFileControlID></ReferenceFileControlID>
<FileHeader>
<Patient>
<seqno> </seqno>
<patientId>Tax ID123</patientId>
<LastName>Lab Name123</LastName>
<FirstName>L</FirstName>
<MiddleName></MiddleName>
<Title> </Title>
<Degree></Degree>
<Street></Street>
<City></City>
<State>HL7.txt</State>
<Zip></Zip>
<patientDOB>1234567</patientDOB>
<gender></gender>
<Patient>
</Report>
Thanks
ManiHi Prabu,
With input as in single line I'm able to get the the output but with the multiple lines of input,error was occured.Any suggestions.
Error while translating. Translation exception. Error occured while translating content from file C:\temp\sampleHL7.txt Please make sure that the file content conforms to the schema. Make necessary changes to the file content or the schema.
The payload details for this rejected message can be retrieved. Show payload...
Thanks
Mani -
How to Splilit The String Into Single Column using Comma As Delimiter ?
How to Splilit The String Into Single Column using Comma As Delimiter ?
using Functionrefer my thread ,code is also available see if that helps you
error while executing the sp ORA-21779: duration not active -
How to write the data into EEPROM using Labview?
How to write the data into EEPROM using Labview?
You would need some sort of EEPROM programmer. Typically might
communicate with it via serial. I don't know how you would do this in
LV. You would need to have the command protocol for the programming
device to start with.
Doug De Clue
gpibssx wrote in message news:<[email protected]>...
> How to write the data into EEPROM using Labview? -
How to write the resultset into a text file
how to write the resultset into a text file
You can use the java.io.* package to write to files.
API: http://java.sun.com/j2se/1.5.0/docs/api/java/io/package-summary.html
Tutorial: http://java.sun.com/docs/books/tutorial/essential/io/index.html
Maybe you are looking for
-
How can I replace an older save file with a new one on game center?
Greetings, I have been trying to change an older game saved file that I have created with my old Ipad with the new one that I have created on my new Ipad, both game files are played under my apple ID but I have no idea how to replace my older one wit
-
My power just went out for a few seconds. Is there any way to restore my document? I had already had 2 hrs worth of work for an interview tomorrow and do not have time to start from scratch?
-
I need to reset my security questions, but can I message support by text and not call or if you can tell me how to reset my questions here that will be great and I don't have a rescue email.
-
Is it possible to associate two iTunes accounts with 1 mac?
My wife and I both share an iMac but have seperate user accounts. Each account is linked to different iCloud accounts. My wife recently purchased an album on here iPad and was wanting to download it to our shared mac but was unable to as her account
-
I place an order last Wednesday for Drakengard 3 (Pre-owned) and still have yet to receive it. According to both the Best Buy and UPS tracking status, UPS delivered the package to the wrong local post office, and it should have been shipped to the co