Variable xml and parser
I have a String containing xml code and i want to parse ths string
but method parse don't accept string so it returns "no protocol : String ".
Could you helpe please, it's very important.
my code (simplified):
String entete_xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
String xml=entete_xml+"<aaa><bbb>aaaa</bbb><essai>reussi</essai></aaa>";
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
doc = builder.parse(xml);
builder.parse(new InputSource(new StringReader(xml)));
Similar Messages
-
Is there a way to load an xml file and parse the tags as we do in javascripts in java?
i want to write a generic xml parser.
what all should i know before starting.
i choose java as my development language.Is there a way to load an xml file and parse the tags
as we do in javascripts in java?Yes?
>
i want to write a generic xml parser.There is one built into Java or you can use JDOM or Dom4J.
>
what all should i know before starting.Difficult to say without knowing what you are doing but the Java tutorial is a good starting point.
i choose java as my development language. -
Eastern European characters in XML and parsing
Hi all,
I have a problem with XML parsing within Java code with special Eastern European characters.
Whenever there is EE character within tags it reports:
WARNING (12847): CORE3283: stderr: org.xml.sax.SAXParseException: The element type "CodeMeaning" must be terminated by the matching end-tag "</CodeMeaning>".
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:134)
Obviously special character is in CodeMeaning XML tag. XML is well formed and syntactically OK and without special characters works OK. Does anyone have any suggestion how to force special characters in XML?Would you send a sample data for test? What is the encoding for your XML doc?
-
How to read XML and parse all child nodes
Here is a sample of my XML file and I want to be able to put into a grid the Server Name, User ID, Password, and then list under all Databases associated with that server.
<Servers>
<Server>
<Name>PROD_Server</Name>
<Database>CUSTOMER</Database>
<Database>LOCATION</Database>
<Database>ORDERS</Database>
<Database>RETURNS</Database>
<UserID>RSMITH></UserID>
<Password>$EWRaZ</Password>
</Server>
<Server>
<Name>WEST_Server</Name>
<Database>OPTIONS</Database>
<Database>PRICES</Database>
<UserID>THAMPTON></UserID>
<Password>$EWRyAQ</Password>
</Server>
<Server>
<Name>PASS_PLUS</Name>
<Database>AUTOMOBILES</Database>
<Database>VINNUMBERS</Database>
<Database>OWNERS</Database>
<UserID>BHARVEY></UserID>
<Password>$VRRaZ</Password>
</Server>
</Servers>
How can I do this?Hello,
Using the xml you supplied I see a master-detail relationship going on which is best shown in at least two DataGridView controls or the master table hooked up to a BindingSourceNavigator then child rows for Database in a DataGridview or label or TextBox
controls.
The code below loads the xml data into a DataSet then uses two BindingSource components to create a master-detail setup that can be setup say in Form load event
Dim ds As New DataSet
ds.ReadXml(IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "XMLFile1.xml"))
Master.DataSource = ds
Master.DataMember = ds.Tables(0).TableName
Details.DataSource = Master
Details.DataMember = ds.Relations(0).RelationName
DataGridView1.DataSource = Master
DataGridView2.DataSource = Details
Declare the BindingSource components at form level
Private Master As New BindingSource
Private Details As New BindingSource
Screenshot using two DataGridView controls.
I would suggest the above as other methods to place all columns into a DataGridView is problematic.
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my webpage under my profile
but do not reply to forum questions. -
Hi all-
I'm new to using spry and xml, but not new to xhtml and layout, having said that. I'm trying to store file paths in my xml and parse that xml to repace <href> tags in an image map. For example (the actual cooridnates in the map are just made up for the example below, the actual map has 88 locations and very detailed coordinates, as it is a state map):
<head>
<script src="../SpryAssets/xpath.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryData.js" type="text/javascript"></script>
var ds1 = new Spry.Data.XMLDataSet("../files/research/counties_census.xml", "ohio");
</head>
<body>
<div spry:region="ds1">
<img src="../images/CountyMap.gif" width="565" height="611" usemap="#Map">
<map id="Map" name="Map">
<area shape="rect" coords="103,156,155,202" href="../files/research/{Location}" />
<area shape="rect" coords="216,156,286,210" href="../files/research/{OtherLocation}" />
</map>
</div>
</body>
Am I just making a syntax error or is this just outside the scope of what I can use spry for? Any help is appreciated.
thanks in advanceI have one more question. What you gave me worked like a charm btw. Thanks a lot. Onto the question:
I'd like to use the same XML to also power a drop down menu, here's a snippet of the XML/XHTML below. I can't seem to get it to work on the drop down, the image map works great.
XML snippet:
<locations>
<location>
<filepath>P1008.pdf</filepath>
<coords>192,496,193,497,194,497,195,497,196,497,197,497,199,497,201,497,201,498,202,498,2 01,498,201,499,202,499,203,500,204,500,204,501,205,502,206,502,206,503,207,503,207,504,207 ,506,207,510,207,511,207,512,207,514,207,518,207,521,207,522,207,524,207,525,207,526,207,5 27,207,528,207,529,207,530,207,531,207,532,207,533,207,535,207,537,207,538,207,539,207,540 ,207,541,207,542,207,543,207,545,207,547,207,548,207,549,207,550,206,552,206,554,206,555,2 06,556,206,558,206,559,206,560,206,562,206,563,206,564,206,565,206,566,206,567,206,568,206 ,569,206,570,206,571,205,571,205,572,204,572,204,573,203,573,203,574,203,573,202,573,201,5 73,201,572,200,572,200,571,200,570,199,570,199,569,199,568,199,567,198,566,197,566,197,565 ,196,565,196,564,195,564,194,564,194,563,193,563,192,563,192,562,191,562,190,562,189,562,1 88,562,187,562,186,562,186,561,187,561,186,561,185,561,184,561,183,561,182,561,182,560,181 ,560,180,560,179,559,178,558,177,557,176,557,176,556,175,556,174,556,174,555,173,555,172,5 55,171,556,169,556,168,556,168,557,167,557,166,557,165,557,164,557,164,558,163,558,162,558 ,161,558,160,559,159,559,159,560,158,560,158,561,158,562,158,563,157,563,157,564,157,565,1 57,566,156,567,155,567,155,568,154,568,153,568,153,567,152,567,151,567,150,566,149,566,149 ,565,149,564,149,563,149,562,149,561,149,560,149,559,149,558,149,557,149,555,150,555,150,5 54,150,553,150,552,150,551,150,549,150,548,150,547,150,546,150,545,150,544,151,543,151,541 ,151,540,151,538,151,537,151,536,151,534,151,532,152,531,152,530,152,529,152,528,152,527,1 52,526,152,525,152,523,152,522,152,521,152,520,152,519,153,519,153,518,153,517,153,516,153 ,515,153,514,153,513,153,512,153,510,153,508,153,507,154,506,154,505,154,504,154,503,154,5 02,155,502,156,502,159,502,160,502,161,502,162,502,163,502,164,502,165,502,165,501,166,501 ,167,501,168,501,169,501,170,501,170,500,171,500,172,500,173,500,174,500,175,500,175,499,1 76,499,177,499,178,499,179,499,180,499,180,498,182,498,184,498,188,497,189,497,190,497,191 ,497</coords>
<county>Adams County</county>
</location>
<location>
<filepath>P1009.pdf</filepath>
<coords>132,183,132,184,132,185,132,186,132,187,132,188,132,189,132,190,132,192,132,194,1 31,195,131,196,131,197,131,199,131,201,131,202,131,203,131,204,131,206,131,207,131,208,131 ,209,131,210,131,211,131,212,131,213,131,214,131,216,131,217,131,218,131,219,131,220,131,2 21,131,223,131,224,131,225,131,226,131,227,131,228,131,229,130,229,129,229,126,229,125,229 ,124,229,123,229,122,229,119,229,118,229,117,229,116,229,114,229,113,229,112,229,111,229,1 10,229,109,229,108,229,107,229,106,229,105,229,104,229,102,229,102,227,102,226,100,226,99, 226,98,226,97,226,96,226,95,226,92,226,90,226,89,226,87,226,87,225,87,224,87,222,87,221,85 ,221,84,221,83,221,82,221,81,221,80,221,78,221,77,221,76,221,75,221,72,221,71,221,69,221,6 8,221,65,221,65,220,65,219,65,218,65,217,65,216,65,215,65,214,65,212,65,211,65,210,65,209, 65,207,65,206,65,205,65,204,65,203,65,201,65,200,65,199,66,199,67,199,68,199,70,199,71,199 ,72,199,73,199,73,197,73,196,73,195,73,194,73,193,73,192,74,192,75,192,76,192,77,192,79,19 2,80,192,81,192,82,192,83,192,84,192,85,192,86,192,87,192,88,192,90,192,91,192,92,192,95,1 92,99,192,100,192,101,192,102,192,102,191,102,190,102,188,102,187,102,186,102,185,105,185, 106,185,107,185,108,185,109,185,110,185,111,185,113,185,114,185,115,185,116,185,117,185,11 7,184,117,183,117,182,118,182,119,182,120,182,121,182,122,182,123,182,124,182,125,182,126, 182,127,182,128,182,129,183</coords>
<county>Allen County</county>
</location>
</locations>
Here's my XHTML:
<div spry:region="ds1">
<p>Click on a county, or select from the following:
<select onchange="jumpMenu(this)" name="menu1">
<option spry:repeat="ds1" value="../files/research/{filepath}">{county}</option>
</select>
</p>
</div>
<div spry:region="ds1"> <img src="../images/OhioCountyMap.gif" usemap="#Map">
<map id="Map" name="Map">
<area spry:repeat="ds1" shape="poly" coords="{coords}" href="../files/research/{filepath}">
</map>
</div> -
Parsing XML and Storing values in instance variable
hi,
i'm new to XML.
here i'm trying to parse an XML and store their element data to the instance variable.
in my main method i'm tried to print the instance variable. but it shows "" (ie it print nothing ).
i know the reason, its becas of the the endElement() event generated and it invokes the characters() and assigns "" to the instance variable.
my main perspective is to store the element data in instance variable.
thanks in advance.
praks
import java.io.*;
import java.net.*;
import java.util.*;
import javax.xml.parsers.*;
import org.xml.sax.*;
import org.xml.sax.helpers.*;
public class mysax extends DefaultHandler
String ctelement;
CharArrayWriter contents;
String vname1,vrcbreg1,vaddress1,vcountry1,vtelephone1,vfax1;
String vname,vrcbreg,vaddress,vcountry,vtelephone,vfax;
public mysax()
vname1 = null;
vrcbreg1 = null;
vaddress1 = null;
vcountry1 = null;
vtelephone1 = null;
vfax1 = null;
contents= new CharArrayWriter();
public void doparse(String url) throws Exception
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
ParserAdapter pa = new ParserAdapter(sp.getParser());
pa.setContentHandler(this);
pa.parse(url);
public void startElement(String namespace,String localName,String qName,Attributes atts)
ctelement = localName;
public void endElement(String uri,String localName,String qName) throws SAXException
public void characters(char[] ch,int start, int length) throws SAXException
try
if(ctelement.equals("name"))
vname = new String (ch,start,length);
System.out.println("The method "+vname1);
}catch (Exception e)
System.out.println("The exception "+e);
public static void main(String args[])
try
mysax ms = new mysax();
ms.doparse(args[0]);
System.out.println("the contents name "+ms.vname1);
catch(Exception e)
System.out.println("this is exception at main" +e);
my XML looks like
<coyprofile_result>
<company>
<name>abcTech</name>
<rcbreg>123456789</rcbreg>
<address>Singapore</address>
<country>sg</country>
<telephone>123456</telephone>
<fax>123155</fax>
</company>
</coyprofile_result>I believe that the problem has to do with the value you assign to ctelement. You are assigning the value of localName to ctElement, however for the element: <name>...</name> the localname is empty string i.e. "", but qName equals "name". Because you are assigning empty string to ctElement, when you do the comparison in characters of ctElement to "name" it will always be false. So in startElement change it to ctElement = qName; Try it and see if it works. I have produced similar programs and it works for me.
Hope this helps. -
Repeated retrieval and parsing of XML file causes IE to display an error message
I have a flash application that makes a HTTP call every 120
seconds to retrieve a xml file. This file is being generated with
fresh data every few minutes or so and pushed to the apache web
root with a unix mv command.
I'm using the standard Flash XML object. The HTTP request is
NOT over SSL (I know there is a bug related to this). Here is the
code to make the retrieval:
xmlData = null;
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = xmlTraverse;
xmlData.load("
http://domain/dir/somefile.xml");
The "xmlTraverse" method was written by my team. There is no
known bug in the parsing logic.
Intermittently and unpredictably, IE will display the
following dialogue box:
"A script in this movie is causing Macromedia Flash Player 8
to run slowly. If it continues to run, your computer may become
unresponive. Do you want to abort the script?"
I originally leaned toward an infinite loop causing this
problem. The timeline jumps back and forth between two frames,
checking in the latter frame if the xml has been loaded and parsed
before allowing execution to move to the next frame. I hardcoded
the loop check to always be false, but this did not produce the
message above (although it pegged my CPU).
The only scenario where I've managed to reproduce the message
above is by making a huge (50 MB) xml file. This consistently
produces the message. But I don't realistically see how our xml
file could ever be over 1 MB.
First, can anyone cite another cause for this message? I'm
starting to lean towards the issue lying in our parsing logic such
as infinite recursion on a badly formed XML file. Second, does
anyone know of a solid xml SAX parsing actionscript utility where
you can assign callbacks to XML nodes? If the problem is in the
parsing, we may have to replace our homegrown solution with
something more robust and proven.Is it a recursive parsing function? I'm not sure about this,
but I think this message pops up when there are more than 256
iterations in a loop (I've read something about this 256 limit,
that will end while loops if they exceed this, but with another
error message... but again, I'm not totally sure about that).
The message is typically for loops, but I don't know when it
fires. Sometimes it appears for really 'small' loops when you're
using the debugger (e.g. a for loop with 100 iterations), so maybe
it is connected to the time a loop is running. You could place some
trace statements in the xmlTraverse method, to see where the
function was when the message occurs, or take the time the function
needs and check if this might be related to the error.
That's all I can come up with, guess there are people here
with more insight to this...
cheers,
blemmo -
Error in retrieving and parsing XML File
Hi Folks
I am Working on People centric user interface, While i am custimizing a application in Business application Builder i am getting this error
" Error in retrieving and parsing XML File "
can any body look on this and give me the solution
it will be rewarded
Regards
M.S.KumarHello,
As mentionned by SAP_TECH, avoid to use the BAB.
Go to CRMC_BLUEPRINT_C and use the different option in the menu to customize the field group, toolbar group, events, ...
Use the PCUI cookbook to find your way.
Regards,
Fred -
I am currently working on an application in which I have a XML file that is 1.5 mb and has 1100 records that I need to load and parse. Loading takes less than a minute, but when I try to parse it with the DOM parser it's taking too much time. I am trying to put it into an array and then display it as if I'm tied to a database. I need a different approach. Does anyone have any experience and insight with the DOM parser? Would the SAX parser be a better way to go, why and how?
You can use SAX... but SAX is good only if you want to read the data once.
If you want to use the same data again and again then you might have to parse the file again... which prooves expensive.
DOM will take too much of memory and CPU time.
Have you tried using JDOM ? it is a new kind of a XML parsing utility that is quite lightweight and has good api to recurse the JDOM tree also.
check it out at
http://www.jdom.org.
hope this helps.
regards,
Abhishek. -
Using CDATA tags in XML program and parsing to J2ME
Hi,
Can anybody tell me how to use CDATA tag in a xml file and parse it to my J2ME code. is there any sample code available for this? I want to use this CDATA tag for sending Binary data. plzzzzzzz Help....!I think what you want is to parse a CDATA text from a xml file and let this text to execute.
Very innovative idea!
If I am right, I think you might mix some concept.
Java code need to be changed to ByteCode before pased to the JVM. Furthermore, Java ME code must be verified before downloading to your machine.
I figure that your attempt is impossible. -
While executing the sample procedure for XML/PLSQL Parser it gives the error:
ERROR at line 1:
ORA-29541: class SCOTT.oracle/xml/parser/plsql/XMLParserCover could not be resolved
ORA-06512: at "SCOTT.XMLPARSERCOVER", line 0
ORA-06512: at "SCOTT.XMLPARSER", line 57
ORA-06512: at "SCOTT.DOMSAMPLE", line 57
ORA-06512: at line 1
While loading the xmlparserv2.jar by using Loadjava I got the resolving problem for some class.
Wht should i do to rectify this error?
Thanks And Regards
Suresh
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Steven Muench ([email protected]):
SELECT TEXT FROM USER_ERRORS
WHERE NAME = DBMS_JAVA.SHORTNAME('oracle/xml/parser/plsql/XMLParserCover')
to see what error is preventing this class from being resolved...<HR></BLOCKQUOTE>
========================
Hello.
I have exactly the same problem and the above SQL does not return any rows.
I upgraded my 8.1.5 on NT to 8.1.6. On trying to install the PL/SQL XML parser, received errors with resolving classes. Suspecting problems with Java VM, I re-installed the JVM using initjvm.sql. On successfull completion, i re-tried installing the parser. Still have the same problems.
Is there anything else i could try?
regards
Krishnan.
null -
Downloading and parsing XML during preload
Apologies if this topic has already been covered but the
search function on the forums doesn't appear to be working for me.
My problem is this. I have a flex app that needs to download
a couple of xml files during initialization that are approximately
2-3 MB each. I'd like for the progress bar to continue showing
until the files are downloaded and parsed and only after the files
are downloaded and parsed, would the components start to be
rendered since some of them will require the files to determine
their look and feel.
Any ideas or places I should look to in order to figure this
out?
Thanks
SangGreg_B,
You could try and access the XML file via a file:// URI rather than an http:// one - this would not need the server to be started in order to get the xml/dtd loaded. You know the relative path to the dtd and xml files, and you can create a File object from there, so you can parse the xml file that way if you like.
Here's some code to help:
String filename = getServletContext().getRealPath("myXML.xml");
You can then pass the filename string as a parameter to the XML (I'm assuming you're using DOM but if you aren't I think you'll still get my point) parse method.
You can do all of this in the servlet's init() method, so it'll do that before it all loads up.
Hope it helps
Daniel -
How to read and parse a remote XML file with Java
Hi.
Using J2SE v1.4.2, I'd like to read and parse a remote file:
http://foo.com/file.xml
Is it possible with Java? I'd be extremely grateful if someone could provide me any webpage showing a very simple code.
Thank you very much.How about the following?
import java.io.InputStream;
import java.net.URL;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
public static void main(String[] args) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
URL url = new URL("http://foo.com/file.xml");
InputStream inputStream = url.openStream();
Document document = db.parse(inputStream);
inputStream.close();
}-Blaise -
Hi all,
is there some procedure or function or whatever I can use to read and parse an XML file into Oracle?
The XML contains 30+ Megs of data, which would represent data in 10+ tables if you would convert it into flat files.
I know I can read the XML and save it line by line in a table, but I do not want to parse it myself. It would be cool if there was a tool or so that would read the dtd definition of the XML, then read the XML data, parse it and create temporary tables with the flat content of the xml (can you code object oriented with PL/SQL? this would even be cooler!).
Does someone have an idea how to do that?
Thanks,
SteffWow, I've never tried to parse an XML file quite that large
before. Does it contain a bunch of encoded binary data, or does it
have houndreds of thousands of xml-nodes?
In any event, I do have one thought:
Do you need absolutely everything in the file? If you only
need access to a small portion of it, it would be worth your while
to pull out only the "stuff" that you need before you parse it. You
could use regular expressions to strip out things you don't need,
or to pull out only the stuff you do need.
The more you can minimize the "parse" effort the better off
you'll be.
Alternatively, if it's a file describing many "records" of
the same type, it would be best if you could "chunk" the file and
parse each record individually. -
Is there any way to parse a XML file and covert it to a result set using SQL and PLSQL?
Yes. Oracle SQL and PL/SQL can use the Oracle supplied XML Parser to create XML and to extract attributes and rows from XML.
Refer to [url http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14259/toc.htm]Oracle® XML DB Developer's Guide.
Maybe you are looking for
-
I used a voucher to validate my account and I still need a card.
I used a voucher to validate my account and i still need a card. I recently purchased an iTunes gift woucher. This was to validate my account as my previous card was about to expire. I did this before and worked fine but my account still wants a card
-
Erratic pointer movement w/ Illustrator
I work a lot with Photoshop and Illustrator and have noticed that my "pointer" is errantic when trying to select and/or move vector points in Illustrator. The only way to eliminate this problem is to go into System's "Accessibility" icon and change m
-
Hi All, I have a requirement where the uploaded file has to get stored in Archive from Webdynpro. I am using the file uploader which is giving me the file name, MIME type and data but I am unable to store it in the Archive. I am using FM 'ARCHIVOBJEC
-
Cannot start J2EE after connecting LDAP
I have just tried to connect my LDAP to the portal (EP6 SR1) and cannot get the J2EE to start....it goes yellow in the MMC but never green. jcontrol.exe says "some processes running". Any one else had this problem. Patrick
-
Upgrading and downgrading between Creative Cloud and Photoshop Photography Program
I am interested in subscribing to the Photoshop Photography Program, but occasionally need to use Premiere and After Effects - is it possible to "upgrade" from the Photoshop Photography Program to the full Creative Cloud (on a per month basis, as nee