Sitemap

Amicuk Programming Answers

How to parse a xml file within a WLST script

2015-10-11   Views:25

Advertisement

Hi all, I'm using ALSB2.6 and I'm writing a WLST script that should read config info from a xml file and create an ALSB prj. I got an error when I call: xmldoc = minidom.parse(sock).documentElement The code: print '#### IPEventConfigFile: ', IPEventC

Hi all,
I'm using ALSB2.6 and I'm writing a WLST script that should read config info from a xml file and create an ALSB prj.
I got an error when I call:
xmldoc = minidom.parse(sock).documentElement
The code:
print '#### IPEventConfigFile: ', IPEventConfigFile
IPEventConfig = loadXML(IPEventConfigFile)
where
def loadXML(source):
sock = open(source)
xmldoc = minidom.parse(sock).documentElement
sock.close()
return xmldoc
The error:
[java] #### IPEventConfigFile: /products/software/terraferma/release3/EventBus/repository/events/DummyEvent/resource/DummyEvent-IPEventConfig.xml
[java] ===============================================================
[java] Unexpected error: exceptions.AttributeError
[java] ===============================================================
[java] No stack trace available.
[java] Unexpected error: exceptions.AttributeError
[java] No stack trace available.
[java] Problem invoking WLST - Traceback (innermost last):
[java] File "/products/software/terraferma/release3/EventBus/scripts/cloning.py", line 198, in ?
[java] File "/products/software/terraferma/release3/EventBus/scripts/cloning.py", line 102, in cloning
[java] File "/products/software/terraferma/release3/EventBus/scripts/cloning.py", line 178, in loadXML
[java] File "Lib/xml/dom/minidom.py", line 908, in parse
[java] File "Lib/xml/dom/minidom.py", line 900, in _doparse
[java] File "Lib/xml/dom/pulldom.py", line 251, in getEvent
[java] AttributeError: feed
Line 178 is:
xmldoc = minidom.parse(sock).documentElement
I'm trying to understand where I'm wrong.
Thanks in advance
ferp

The replay answer
Advertisement
Using the SAXParser in JAXP the parsing of the XML file is event driven.
Instantiate the parser:
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
InputSource is = new InputSource(new FileReader(theXML));call the parse method:
parser.parse(is, this);The following events are fired as the parser works through the XML public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws org.xml.sax.SAXException
public void endElement(String namespaceURI, String localName, String qName) throws org.xml.sax.SAXException
characters(char[] ch, int start, int length)etc.
You write what you want within each of these sections to handle the structure of your data. Keep in mind SAX is useful only when you know the structure of your XML.

Go to See the other 3 answers

How to parse a xml file within a WLST script

Category:DefaultRelease time:2015-10-11Views:130

Hi all, I'm using ALSB2.6 and I'm writing a WLST script that should read config info from a xml file and create an ALSB prj. I got an error when I call: xmldoc = minidom.parse(sock).documentElement The code: print '#### IPEventConfigFile: ', IPEventC[More]

Can someone help me with a problem of parsing an XML file?

Category:DefaultRelease time:2015-10-11Views:130

Hello, I'm having some problems parsing an xml file. I get a SAXNotSupportedException when setting a property value. Here is the piece of code where I have the problem: SAXParserFactory spf = SAXParserFactory.newInstance(); spf.setNamespaceAware(true[More]

Parsing of xml file in oracle stored procedure on linux server

Category:DefaultRelease time:2015-10-11Views:130

We have an XML file in the "/database/stats/dev/xml1/" path and tried to parse the file using the below code : p := xmlparser.newParser; xmlparser.setValidationMode(p, FALSE); -- xmlparser.setErrorLog(p, errfile); xmlparser.setBaseDir(p, dir); x[More]

How to Parse an XML file using SAXParser in java.

Category:DefaultRelease time:2015-10-11Views:130

Hi all Am a bit new to XML files and have no idea about SAXParsers ... Now my problem is to parse this XML file below <?xml version="1.0" encoding="UTF-8"?> <sc:memory_segmentation xmlns:sc="sc_memory_segmentation.xsd&quo[More]

Parsing an XML file

Category:DefaultRelease time:2015-10-11Views:130

I've written a program which is partly responsible for parsing an XML file that can be found on the web. I appear to be accessing the XML file correctly, but when I try to parse it I am running into a problem. I try to create a List object that conta[More]

Parse exisitng xml file and recreate another xml file with different struct

Category:DefaultRelease time:2015-10-11Views:130

Is it possible in java using dom parser to parse an exisiting xml file and recreate a new xml file from data obtained by parsing old xml file. I checked on old forum threads and everywhere either parsing xml file has been explained or creating new xm[More]

Parsing a XML file using Jdom-Problem.

Category:DefaultRelease time:2015-10-11Views:130

Hi all, I am reposting it as I was told to format the code and send it again. I am trying to parse a xml file using a jdom java code.This code works fine if I remove xmlns attribute in the root element. (I get the expected result) .If the "xmlns"[More]

How to parse a XML file

Category:DefaultRelease time:2015-10-11Views:130

I am a new learner to XML & JAVA,I dont't know how to parse the XML file using JAXP,Who can tell me,Who can write an Example? thx Best Regards.Using the SAXParser in JAXP the parsing of the XML file is event driven. Instantiate the parser: SAXParserF[More]

Can Document Builder parse an XML file from a URL?

Category:DefaultRelease time:2015-10-11Views:130

Warning: Java newbie here... My problem is that I am able to parse an XML file if it is copied into my project, but not if it is a full URL. Here is what I got so far, that works. import java.io.*; import java.net.*; import javax.xml.parsers.Document[More]

Error "Cannot parse appinfo xml file."

Category:DefaultRelease time:-0001-11-30Views:130

Periodically my users are getting the error below when trying to launch BPC for Excel: "Cannot parse appinfo xml file." Seems this file is getting corrupted somehow. If I remove the file from their citrix profile and they relogin, the file is re[More]

How quickly parse big XML file (60 MB) ???

Category:DefaultRelease time:-0001-11-30Views:130

How quickly parse big XML file (60 MB) ???I assume you mean load it into XML DB ?. Fundamentally your document is about the upper limit for 9.2.x. I would strongly recommend trying to break it up into a set of smaller documents using a SAX parser bef[More]

Hot
hi there, I had a bad sector on my hard drive, so i couldn't boot my machine. I had a diskwarrior cd, so i rebuilt the volume. AFter process, the machine restarted, and ejected the cd. I went to put it back in, and pop grrrrr buzz dvd drive crapped o [More]
I was doing homework on masteringgenetics and there was this box in the top left hand corner that said to allow java deployment toolkit because some of the content on the website needed it so I clicked "always allow". This then took me to java's [More]
Hello Experts, I am looking for a way to send payment notifications in SD, to be clear I need an email to be sent when a specific type of invoice gets paid. I want to send an email to specific email address (not the customers) is this possible using [More]
Good Day Everyone We want our sharepoint site to have a password expiration functionality, when the users are logging in on our site, is this possible? if yes how? i'm using a FBA SQL membership and i have a custom login page for my sharepoint site. [More]
Dear friends,     I am learning SAP BW, and I need to practice some test cases to make myself comfortable. I want to install SAP R/3 on a seperate external hard disk and configure to my system. <b>Can anybody from <b>"BANGALORE"</ [More]
Anyone knows how to export ROLES and SYNONYMS with exp/imp commands? Help is needed. Thanks.Hi, Pls. post this query in RDBMS forum since Portal export import forum does not handle this. Thanks, ~Kirit.Read other 2 answers [More]
Adobe Active X did not work very well to edit a PDF file so I did not want to purchase it; HOWEVER now I am unable to uninstall it and also unable to use Adobe Acrobat to view PDFs. I am a business person and there are pdf's I must view ASAP, somebod [More]
Hi all, DB13 jobs are cancelled due to "Permission denied" error. I pasted the error log below. Actually we have upgraded database from Oracle 9 to 10, then after these jobs are cancelling before that this was fine. What could be the problem cou [More]
Hello, I own a Toshiba L655-S5096 (It has a chicony USB 2.0 built-in webcam). I hadn't used it for quite a while after I purchased it in 2010. Recently I tried using skype on my laptop, but it said that it couldn't detect any webcam. I thought maybe [More]
What's the story...? Neither Lightroom nor photoshop can open CR2 files from my new Canon rebel T3i? I've never had an issue with raw files as I have a bunch of canon cameras. Canon says it's not their problem. Is this on Adobe? I don't understand th [More]