Skip to content.

Find topic

Web tools

Help

Tools

       Analysis Tool Bar  +

Extract from xml tool

See: http://taporware.mcmaster.ca/~taporware/xmlTools/xmlquery.shtml

Description

The Extract from xml tool allows you to specify an element or attribute/value combination and extract all the elements that match. Thus one can extract the paragraph elements from an XML file. You can use an XPath in the "Element" field for more complicated extraction.

History

Pseudocode

  • Obtain XML string by URL or from user's local disk
  • Extract text based on user specified element(s)
  • Generate output based on user specified display format

Ways of Using

  • Enter a valid URL in the URL field or enter a local upload html text (Note: this text must be xml)
  • Enter valid xml element names of the input xml source seperated by comma, default is "//"
  • If you want to specify attribute, enter them in the corresponding fields in pairs
  • Select output format
  • Click "submit" button

XPath

To retrieve using XPath you enter the XPath into the "Element" field. For example, //Xitem[Xdate[@xyear='2007']] will retrieve all parent elements "Xitem" whose "Xdate" child has the "xyear" attribute with a value of "2007". This would return the whole "Xitem" that might include an "Xtext" element that is a sibling to "Xdate" and has the text you want.

CGI Interface

If you want to use this tool from your web site, here is the CGI Interface: (Note: you need to use attribute name/value pair: enctype="multipart/form-data" within the form tag because the script is written with file uploading in mind)

Here are the parameters:

Parameter Name Parameter Value Control Type Default Discription
source url/local radio button url Let user select input text (either a url or upload local xml text)
xmlurl   text   A valid URL that the pointed document should be an xml text
localFile   file   The path to your local xml text file
xmlpath   text // Valid xml element names (paths) or multple xml element names (paths) separated by comma
attr_name   text   Valid xml attribute name of the input xml docs
attr_value   text   Valid xml attribute value corresponding to the attribute name
HowToDisplay 1/2/3 selection 1 Display format which are HTML/XML text in HTML/XML tree in the order of parameter values
taporface   checkbox checked display result in a new window without graphics interface (default) or with taporware interface in the same window

Web Service Interface

Taporware provides web services to any non-benefit organizations. Here is the taporware web services infomation:

  • Endpoint URL: http://taporware.mcmaster.ca:9982
  • Service URI: http://taporware.mcmaster.ca/~taporware/webservice
  • Service Method: extract_Text_XML
  • parameters:
    • xmlInput -- any xml string
    • element -- any valid xml element name in the input xml text
    • attributeName -- any valid attribute name in the input xml text
    • attributeValue -- the attribute value corresponding to the attribute name above
    • outFormat -- values are same as parameter "textdisp" in the CGI interface above

Known Bugs

To Do

  • We need to add an X-Path field to the Subtext limited to panel so one can specify more complicated subtexts.

-- GeoffreyRockwell - 17 May 2005


Use this box to quickly add a comment to the page.

more options...