Search Results

Search found 8 results on 1 pages for 'mkp'.

Page 1/1 | 1 

  • HTML Parsing for multiple input files using java code [closed]

    - by mkp
    FileReader f0 = new FileReader("123.html"); StringBuilder sb = new StringBuilder(); BufferedReader br = new BufferedReader(f0); while((temp1=br.readLine())!=null) { sb.append(temp1); } String para = sb.toString().replaceAll("<br>","\n"); String textonly = Jsoup.parse(para).text(); System.out.println(textonly); FileWriter f1=new FileWriter("123.txt"); char buf1[] = new char[textonly.length()]; textonly.getChars(0,textonly.length(),buf1,0); for(i=0;i<buf1.length;i++) { if(buf1[i]=='\n') f1.write("\r\n"); f1.write(buf1[i]); } I've this code but it is taking only one file at a time. I want to select multiple files. I've 2000 files and I've given them numbering name from 1 to 2000 as "1.html". So I want to give for loop like for(i=1;i<=2000;i++) and after executing separate txt file should be generated.

    Read the article

  • Groovy pretty print XmlSlurper output from HTML?

    - by Misha Koshelev
    Dear All: I am using several different versions to do this but all seem to result in this error: [Fatal Error] :1:171: The prefix "xmlns" cannot be bound to any namespace explicitly; neither can the namespace for "xmlns" be bound to any prefix explicitly. I load html as: // Load html file def fis=new FileInputStream("2.html") def html=new XmlSlurper(new org.cyberneko.html.parsers.SAXParser()).parseText(fis.text) Versions I've tried: http://johnrellis.blogspot.com/2009/08/hmmm_04.html import groovy.xml.StreamingMarkupBuilder import groovy.xml.XmlUtil def streamingMarkupBuilder=new StreamingMarkupBuilder() println XmlUtil.serialize(streamingMarkupBuilder.bind{mkp.yield html}) http://old.nabble.com/How-to-print-XmlSlurper%27s-NodeChild-with-indentation--td16857110.html // Output import groovy.xml.MarkupBuilder import groovy.xml.StreamingMarkupBuilder import groovy.util.XmlNodePrinter import groovy.util.slurpersupport.NodeChild def printNode(NodeChild node) { def writer = new StringWriter() writer << new StreamingMarkupBuilder().bind { mkp.declareNamespace('':node[0].namespaceURI()) mkp.yield node } new XmlNodePrinter().print(new XmlParser().parseText(writer.toString())) } Any advice? Thank you! Misha

    Read the article

  • replace XmlSlurper tag with arbitrary XML

    - by Misha Koshelev
    Dear All: I am trying to replace specific XmlSlurper tags with arbitrary XML strings. The best way I have managed to come up with to do this is: #!/usr/bin/env groovy import groovy.xml.StreamingMarkupBuilder def page=new XmlSlurper(new org.cyberneko.html.parsers.SAXParser()).parseText(""" <html> <head></head> <body> <one attr1='val1'>asdf</one> <two /> <replacemewithxml /> </body> </html> """.trim()) import groovy.xml.XmlUtil def closure closure={ bind,node-> if (node.name()=="REPLACEMEWITHXML") { bind.mkp.yieldUnescaped "<replacementxml>sometext</replacementxml>" } else { bind."${node.name()}"(node.attributes()) { mkp.yield node.text() node.children().each { child-> closure(bind,child) } } } } println XmlUtil.serialize( new StreamingMarkupBuilder().bind { bind-> closure(bind,page) } ) However, the only problem is the text() element seems to capture all child text nodes, and thus I get: <?xml version="1.0" encoding="UTF-8"?> <HTML>asdf<HEAD/> <BODY>asdf<ONE attr1="val1">asdf</ONE> <TWO/> <replacementxml>sometext</replacementxml> </BODY> </HTML> Any ideas/help much appreciated. Thank you! Misha p.s. Also, out of curiosity, if I change the above to the "Groovier" notation as follows, the groovy compiler thinks I am trying to access the ${node.name()} member of my test class. Is there a way to specify this is not the case while still not passing the actual builder object? Thank you! :) def closure closure={ node-> if (node.name()=="REPLACEMEWITHXML") { mkp.yieldUnescaped "<replacementxml>sometext</replacementxml>" } else { "${node.name()}"(node.attributes()) { mkp.yield node.text() node.children().each { child-> closure(child) } } } } println XmlUtil.serialize( new StreamingMarkupBuilder().bind { closure(page) } )

    Read the article

  • Problem with UPDATE statement in stored-procedure in Oracle Database

    - by MKP
    Hello, I have stored-procedure in Oracle database like this: create or replace PROCEDURE EDYTUJ_PRACOWNIKA (PR_IMIE IN VARCHAR2, PR_NAZWISKO IN VARCHAR2, PR_PENSJA IN FLOAT, PR_PRZELOZONY IN NUMBER, PR_ODDZIAL IN NUMBER, PRAC_ID IN NUMBER) AS tmpPensja FLOAT := 0; tmpPrzel NUMBER := 0; BEGIN select przelozony into tmpPrzel from pracownik where id = PRAC_ID; IF(tmpPrzel IS NOT NULL) THEN select pensja into tmpPensja from pracownik where id = tmpPrzel; IF(tmpPensja < 1150) THEN UPDATE PRACOWNIK SET pensja = 1000 WHERE id = tmpPrzel; ELSE UPDATE PRACOWNIK SET pensja = pensja - 150 WHERE id = tmpPrzel; (4) END IF; END IF; IF(PR_PRZELOZONY > 0) THEN UPDATE PRACOWNIK SET imie = PR_IMIE, nazwisko = PR_NAZWISKO, pensja = PR_PENSJA, przelozony = PR_PRZELOZONY, oddzial = PR_ODDZIAL WHERE id = PRAC_ID; (2) select pensja into tmpPensja from pracownik where id = PR_PRZELOZONY; IF(tmpPensja > 4850) THEN UPDATE PRACOWNIK SET pensja = 5000 WHERE id = PR_PRZELOZONY; ELSE UPDATE PRACOWNIK SET pensja = pensja + 150 WHERE id = PR_PRZELOZONY; (1) END IF; ELSE UPDATE PRACOWNIK SET imie = PR_IMIE, nazwisko = PR_NAZWISKO, pensja = PR_PENSJA, przelozony = NULL, oddzial = PR_ODDZIAL WHERE ID = PRAC_ID; (3) END IF; END; where przelozony and pensja are columns in pracownik table. And I have problem that when running procedure with parameters that provide that line marked with "(1)" (there is the same problem with line marked with "(4)") should be executed that update statement don't have any effect. What's more statements in lines marked with "(2)" and "(3)" works fine. I have no ideas how to fix it. Thank you in advance for your help.

    Read the article

  • XmlSlurper/NekoHTML document fragment parsing - No HTML or BODY tags wanted

    - by Misha Koshelev
    Dear All, I am trying to parse the following HTML fragment, and I would like to get the same fragment as output (without HTML and BODY tags). Is this possible? If so, how? Thank you Misha p.s. I am reading here: http://nekohtml.sourceforge.net/faq.html#fragments and I believe I have added the correct options below. However, the output is still incorrect :( Thank you Misha import groovy.xml.MarkupBuilder import groovy.xml.StreamingMarkupBuilder import groovy.util.XmlNodePrinter import groovy.util.slurpersupport.NodeChild def text=""" <div><h2>Test</h2> <div>Hi</div> </div> """ // Parse def config=new org.cyberneko.html.HTMLConfiguration() config.setFeature("http://cyberneko.org/html/features/balance-tags/document-fragment",true) def html=new XmlSlurper(new org.cyberneko.html.parsers.SAXParser()).parseText(text) // Output def printNode(NodeChild node) { def writer = new StringWriter() writer << new StreamingMarkupBuilder().bind { mkp.declareNamespace('':node[0].namespaceURI()) mkp.yield node } new XmlNodePrinter().print(new XmlParser().parseText(writer.toString())) } printNode(html) Output: <HTML> <tag0:HEAD xmlns:tag0="http://www.w3.org/1999/xhtml"/> <BODY> <DIV> <H2> Test </H2> <DIV> Hi </DIV> </DIV> </BODY> </HTML>

    Read the article

  • Wget site mirror, links with rel="<content>" not followed

    - by Pacifika
    Whilst creating a site mirror using wget 1.12 on Ubuntu links with a rel attribute set are not downloaded: <a href="link" rel="tag">text</a> Rel="tag" is a microformat (By adding rel="tag" to a hyperlink, a page indicates that the destination of that hyperlink is an author-designated "tag" (or keyword/subject) for the current page). My WordPress theme uses this for link to tags, so 99% of the site is ignored. Edit: it turns out all my permalinks use rel="bookmark" and are skipped as well. I'm using the following wget command (this ignores robots.txt and also follows nofollow links): wget -mkp -e robots=off http://site How do I make wget follow links with rel set?

    Read the article

  • Groovy MarkupBuilder causing java.lang.NoClassDefFoundError on closure in soapUI

    - by Eric
    I am not able to get the Groovy MarkupBuilder to work with soapUI. I am very new to Groovy and I am just following one of the user guides on creating XML. Testing a very simple method: public String Example(){ def writer = new StringWriter() def root = new MarkupBuilder(writer) root.mkp.xmlDeclaration(version:"1.0", encoding:"UTF-8") root.Root{ Example("A") } return writer.toString() } I get the following error in soapUI: ava.lang.NoClassDefFoundError: MockXML$_Example_closure2 I have no error when I run from Groovy Console. In the same class I have: public String Hello(){ return "Hello" } Which works fine in soapUI. Is there something I would need setup/imported/configured in soapUI that I am not thinking about to handle MarkupBuilder/closures? Thanks

    Read the article

  • Android stream to Wowza

    - by Curtis Kiu
    I feel very confused about Android streaming to wowza. I am doing a video conference using rtmp cross-platform, but Android doesn't eat RTMP. Therefore I need to find another way to do it. Upstreaming I found a new open-source app called spydroid-ipcamera. It is using rtp, sending udp packets to computer, and opens it in vlc using the following sdp v=0 s=Unnamed m=video 5006 RTP/AVP 96 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1;profile-level-id=420016;sprop-parameter-sets=Z0IAFukBQHsg,aM4BDyA=; But it can't work. Then I follow wowza tutorial and stream to it and then play again in VLC. That works! I wrote it in http://code.google.com/p/spydroid-ipcamera/issues/detail?id=2 However when I want to add audio in the packet, it fails to work. I change to code in http://code.google.com/p/spydroid-ipcamera/source/browse/trunk/src/net/mkp/spydroid/CameraStreamer.java mr.setAudioSource(MediaRecorder.AudioSource.MIC); mr.setVideoSource(MediaRecorder.VideoSource.CAMERA); mr.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mr.setVideoFrameRate(20); mr.setVideoSize(640, 480); mr.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); mr.setVideoEncoder(MediaRecorder.VideoEncoder.H264); mr.setPreviewDisplay(holder.getSurface()); Then I thought that the problem should be in sdp, but I don't know how to due with sdp. I am streaming H.264/AAC with Mp4 Second I don't understand sdp. So how can I make video conference upstreaming part using this apps. Android ----(UDP Port:5006)----> PC (SDP file) and then Wowza read the SDP file ------> VLC I think in this way the system cannot handle more than 1 client. sdp can only hold 1 port, any idea or actually it wont' work? Also Wowza need to set the stream before we stream it, so does it mean that I should not follow this way to do it? Sorry my English is poor, I hope you guys understand.

    Read the article

1