r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[XML] xml related conversations

Pekr
10-Nov-2008
[556x3]
you should be able to simulate even submit, no? Browser generates 
http action for it after all ... Maybe it would be good to watch 
packets in WireShark, or install FF plug-in for displaying http headers 
...
Web developer extension and FireBug are kind of must-have extensions 
....
Live HTTP headers is the one I use ....
Tomc
10-Nov-2008
[559]
Ashley  it looks just like what is after the ? in a GET to a  *.cgi?name="value"&N2="v2"
Ashley
10-Nov-2008
[560]
Ah, thanks. I'll give that a go.
Gabriele
10-Nov-2008
[561]
ashley, look at the source for the page, and search for the <form> 
tag. if method="GET", as Tom said, look at the url after pressing 
the submit button and just do a read on a similarly composed url. 
if method="POST", you need to look at all the <input> tags, figure 
out what the query string would be, and send it via POST using read/custom. 
(you could also use wireshark or similar to look at the query string 
the browser is sending if you don't want to look for the <input> 
tags)
Ashley
11-Nov-2008
[562]
All works, "read/custom url reduce ['POST query-string]" did the 
trick! Thanks guys.

My little 64 line script now does the following:


 1) Read Address Book vCard file and extract a list of number/name 
 pairs (I prefix the numbers with 'n to assist with lookups)

 2) Read each Linksys SPA942 IP Phone's call history and create a 
 sorted list of number/frequency pairs

 3) Join these 2 lists and create a query string for matches and an 
 exception report for numbers without an address book entry
	4) POST merged and updated name/number pairs back to each phone


Script took 2 hours to write and debug, runs in 2-3 seconds and gives 
us the features of an advanced call management facility for free. 
Once again, REBOL to the rescue (my business partner shook his head 
when he saw this and just said, "but HOW can REBOL do all this???").
Arthur
11-Nov-2008
[563x3]
wow
amazing
Such things are unheard of around here.
Geomol
11-Nov-2008
[566]
:-) Good work, Ashley!
Henrik
11-Nov-2008
[567]
Great stuff. I did something similar once. REBOL is fantastic as 
"impossible gluelogic".
Geomol
11-Nov-2008
[568]
REBOL is GLUE! What about calling the new GUI something related to 
glue? Or just "GLUE".
Steeve
11-Nov-2008
[569]
It's also a refernce to the "special" talent of Carl in terms of 
mixing colors ;-)
Geomol
11-Nov-2008
[570]
:)
Henrik
11-Nov-2008
[571]
it's at times like that, that REBOL deserves advertising with a live 
demo.
Steeve
11-Nov-2008
[572x6]
the first time i saw his new styles, i had some glue in my eyes
is Henrik steel working on revamping ?
*still
oh you're here...
oh i have a better bad puns: GUI-lty
or worst, as u want
Chris
19-Nov-2008
[578x2]
This is a quickie -- designed to make 'parse-xml output more parseable:

http://www.ross-gill.com/r/qxml.r

Any thoughts, comments?
; Usage:

do http://www.ross-gill.com/r/qxml.r
load-xml {<some xml="to">Try</some>}
Gregg
19-Nov-2008
[580]
** Script Error: pop has no value
** Where: load-xml
** Near: mk: insert mk: back mk
Chris
19-Nov-2008
[581x2]
Sorry, forgot I'd assigned pop: :take -- try again.
A tag block will always be [tag! any [refinement! [string! | none!]] 
[string! | none! | block!]]
Gregg
19-Nov-2008
[583]
Cool.
Chris
19-Nov-2008
[584x2]
Sorry, [tag! any [refinement! [string! | none!]] [string! | none! 
| some block!]]
Sorry!
Chris
3-Dec-2008
[586x17]
I've changed this a little.  More or less parseable.
More consistent, I feel.  The result is now of the format: some [thing 
value]
Where 'thing is <tag> /attribute or # for text.  And value is [container] 
"text" or none
>> load-xml {<some xml="to">Try</some>}
==  [
	<some>
		/xml "to"
		# "Try"
	]
]
Hmm, missing bracket.
I thought about the # convention.  # can be used in parse literally. 
 It may have no semantic meaning, but is a very concise anchor.
Also, a tag with no attributes containing only text will only contain 
text:
>> load-xml "<try>This</try>"
== [
    <try> "This"
]
response: context [
	status: name: value: none
]

example: {<rsp>
	<status>Good</status>
	<payload>
		<value name="one">two</value>
	</payload>
</rsp>}

probe make response [
	parse load-xml example [
		<rsp> into [
			<status> set status ["Good" | "Bad"]
			<payload> into [
				<value> into [
					/name set name string! # set value string!
				]
			]
		]
	]
]
All the 'into values are a bit of a pain, but work can be broken 
up...
Note, this parser is destructive - ie. flattening will only provide 
an approximation of the original xml string.
So ymmv depending on need.
; Next, Quick DOM:

do http://www.ross-gill.com/r/qdom.r
Only one method at the moment - get-by-tagname


Note, this is not an attempt to implement W3 DOM.  Just a quick approximation 
for fast manipulation (hence the name).  It's object happy, not sure 
of the weight considerations as such.
do http://www.ross-gill.com/r/qdom.r

doc: load-dom {<some><xml>to try</xml></some>}
values: doc/get-by-tagname <xml>
values/1/value = "to try"
; You can still parse the tree too:
parse doc/tree [<some> into [<xml> "to try"]]
This is not an exercise in bloat, I plan to implement only a few 
key methods.  Though if anyone has any requests?
Chris
4-Dec-2008
[603]
Ok, another revision.  This has a few more methods, I may strip them 
down to read-only, as I don't need to manipulate the object though 
I left them in for completeness.

>> do http://www.ross-gill.com/r/qdom.r
connecting to: www.ross-gill.com
Script: "QuickDOM" (none)
>> doc: load-dom {<some><xml id="foo">to try</xml></some>}
>> foo: doc/get-by-id "foo"
>> foo/name
== <xml>
>> foo/value
== [
    /id "foo" 
    # "to try"
]
>> kids: foo/children
== [make object! [
        name: #
        value: "to try"
        tree: [
            # "to try"
        ]
        position: [
   ...
>> kids/1/value
== "to try"
>> doc/tree/<some>/<xml>/(#)           
== "to try"
Geomol
2-Mar-2009
[604]
RebXML spec: http://www.fys.ku.dk/~niclasen/rebxml/rebxml-spec.html
Scripts are in the Library: http://www.rebol.org
Graham
22-Jun-2009
[605]
Has anyone written anything to format/index XML documents?