Parse xml for newline chars using xpath

Hi guys,
need your help.
I was curious to how can we use subString-before and subString after function to extracts records based on newline.
Ex.
for an strin xml field with data
1st line
2nd line
and want to extract each line as separate record.
Hope i am clear on req.
anybody done something similar before?
Thanks in advance.

While SOA is based on handling XML messages, it has no relation with a presentation layer. Characters such as new-line, line-feed are processed as whitespace.
If you want to add specific characters, you must encode this. So a new line would be 
 This also applies for characters like quote and less-then and greater then.
You must encode your information into UTF8 format.
Marc
http://orasoa.blogspot.com

Similar Messages

  • Parsing xml for complex type using sax

    I have an xsd of below type:
    <xs:complexType name="itemInfo">
        <xs:sequence>
          <xs:element name="displayLineNumber" type="xs:string" minOccurs="0"/>
          <xs:element name="lineNumber" type="xs:integer" minOccurs="0"/>
          <xs:element name="parentLineNumber" type="xs:integer" minOccurs="0"/>
       <xs:element name="service" type="serviceInfo" minOccurs="0" maxOccurs="unbounded"/>
       </xs:sequence>
    </xs:complexType>
    <xs:complexType name="serviceInfo">
        <xs:sequence>
          <xs:element name="displayLineNumber" type="xs:string" minOccurs="0"/>
          <xs:element name="lineNumber" type="xs:integer" minOccurs="0"/>
          <xs:element name="serviceName" type="xs:string" minOccurs="0"/>
          <xs:element name="serviceDescription" type="xs:string" minOccurs="0"/>
          <xs:element name="subscriptionBand" type="subscriptionBandInfo" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="subscriptionBandInfo">
        <xs:sequence>
          <xs:element name="min" type="xs:long"/>
          <xs:element name="max" type="xs:long"/>
          <xs:element name="duration" type="xs:string" minOccurs="0"/>
          <xs:element name="price" type="xs:decimal"/>
        </xs:sequence>
      </xs:complexType>
    I have written a handler and able to handle simple type but how I can handle serviceInfo and subscriptionBandInfo as itemInfo is my root element.
    My handler class is:
    public class ProductHandler
      extends DefaultHandler
      //List to hold ProductInfo object
      private List<ProductInfo> productList = null;
      private ProductInfo product = null;
      public List<ProductInfo> getProductList()
        return productList;
      boolean bDisplayLineNumber = false;
      boolean bLineNumber = false;
      boolean bParentLineNumber = false;
      @Override
      public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException
        if (qName.equalsIgnoreCase("item"))
        { //create a new ProductInfo and put it in Map
          //initialize ProductInfo object and set id attribute
          product = new ProductInfo();
          //initialize list
          if (productList == null)
            productList = new ArrayList<ProductInfo>();
        else if (qName.equalsIgnoreCase("name"))
          //set boolean values for fields, will be used in setting ProductInfo variables
          bName = true;
        else if (qName.equalsIgnoreCase("displayLineNumber"))
          bDisplayLineNumber = true;
        else if (qName.equalsIgnoreCase("lineNumber"))
          bLineNumber = true;
        else if (qName.equalsIgnoreCase("parentLineNumber"))
          bParentNumber = true;
      @Override
      public void endElement(String uri, String localName, String qName)
        throws SAXException
        if (qName.equalsIgnoreCase("item"))
          //add ProductInfo object to list
          productList.add(product);
      @Override
      public void characters(char ch[], int start, int length)
        throws SAXException
       if (bDisplayLineNumber)
          product.setDisplayLineNumber(Integer.parseInt(new String(ch, start, length)));
          bDisplayLineNumber = false;
       else if (bLineNumber)
          product.setLineNumber(Integer.parseInt(new String(ch, start, length)));
          bLineNumber = false;
        else if (bParentNumber)
          product.setParentNumber(Integer.parseInt(new String(ch, start, length)));
          bParentNumber = false;
      @Override
      public void endElement(String uri, String localName, String qName)
        throws SAXException
        if (qName.equalsIgnoreCase("item"))
          //add ProductInfo object to list
          productList.add(product);
    My ProductInfo class is:
    import com.vpc.schema.ServiceInfo;
    import java.util.ArrayList;
    import java.util.List;
    public class ProductInfo
      private String category, family, subGroup, size, productType, availability;
      private String displayLineNumber;
      private int lineNumber;
      private int parentNumber;
    private List<ServiceInfo> serviceInfo;
      public int getLineNumber()
        return lineNumber;
      public int getParentNumber()
        return parentNumber;
      public List<ServiceInfo> getServiceInfo()
        if (serviceInfo == null)
          serviceInfo = new ArrayList<ServiceInfo>();
        return serviceInfo;
      public void setServiceInfo(List<ServiceInfo> serviceInfo)
        this.serviceInfo = serviceInfo;
    I am able to do parsing for my simple type but when a complex type comes I am not able to do it. So please suggest how I can add complex type

    I suppose the posting of xsd is to show the structure of the xml...
    In any case, I can suggest a couple of things to do for the purpose.
    [1] If you still follow the same line of reasoning using some boolean like bDisplayLineNumber etc to identify the position of the parser traversing the document, you can complete the logic adding bItem (which you did not need under simplified consideration) and bService and bSubscriptionBand to identify at the parent or the grandparent in the case of the "complexType" serviceInfo and even the great-grand-parent in the case of arriving to the complexType subscriptionBandInfo...
    [1.1] With those boolean value, you determine bDisplayLineNumber etc under item directly, and then as well say bDisplayLineNumber_Service under the service etc and then bMin_SubscriptionBand etc under subscriptionBand etc. You just expand the number of those variables to trigger the setting of those fields in the object product, service in the serviceList and subscriptionBand in the subscriptionBandList etc etc.
    [1.2] All the reset of those booleans should be done in the endElement() method rather than in characters() method. That is logically more satisfactory and has a bearing in case there is a mixed content type.
    [1.3] Then when arriving at startElement of service, you make sure you initiate the serviceList, same for subscriptionBand the subscriptionList...
    [1.4] Then when arriving at endElement of service, you use setServiceInfo() setter to pass the serviceList to product and the same when arriving at endElement of serviceBand, you use setSubscriptionBand() setter to pass the subscriptionBand to service.
    ... and then basically that's is it, somewhat laborious and repetitive but the logical layout is clear. (As a side-note, you shouldn't use equalsIgnoreCase(), why should you? xml is case sensitive.)
    [2] Actually, I would suggest a much neater approach, especially when you probe many more levels of complexType. It would be even appear cleaner when you have two levels of depth already...
    [2.1] You maintain a Stack (or an implementation class of Deque, but Stack is largely sufficient here) of element name to guide the parser identifying its whereabout. By such doing, you get ride of all those bXXX's.
    This is a rewrite of the content handler using this approach and I only write the code of capturing service. Adding serviceBand is a matter of repetition of how it is done on service. And it is already clear it appears a lot neater as far as I'm concerned.
    public class ProductHandler extends DefaultHandler {
    Stack<String> tagstack=new Stack<String>();
    private List<ProductInfo> productList = null;
    private ProductInfo product = null;
    private List<ServiceInfo> serviceList=null;
    private ServiceInfo service=null;
    public List<ProductInfo> getProductList() {
      return productList;
    public List<ServiceInfo> getServiceList() {
      return serviceList;
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes) {
      if (qName.equals("item")) {
       product = new ProductInfo();
       //initialize list
       if (productList == null) {
        productList = new ArrayList<ProductInfo>();
      } else if (qName.equals("service") && tagstack.peek().equals("item")) {
       service=new ServiceInfo();
       if (serviceList==null) {
        serviceList=new ArrayList<ServiceInfo>();
      tagstack.push(qName);
    @Override
    public void endElement(String uri, String localName, String qName) {
      if (tagstack.peek().equals("item")) {
       //add ProductInfo object to list
       productList.add(product);
      } else if (tagstack.peek().equals("service") && tagstack.search("item")==2) {
       serviceList.add(service);
       product.setServiceInfo(serviceList);
      tagstack.pop();
    @Override
    public void characters(char ch[], int start, int length) throws SAXException {
      String currentName=tagstack.peek();
      int itemPos=tagstack.search("item");
      int servicePos=tagstack.search("service");
      if (currentName.equals("name") && itemPos==2)  {
       product.setName(new String(ch, start, length));
      } else if (currentName.equals("displayLineNumber") && itemPos==2) {
       product.setDisplayLineNumber(Integer.parseInt(new String(ch, start, length)));
      } else if (currentName.equals("lineNumber") && itemPos==2) {
       product.setLineNumber(Integer.parseInt(new String(ch, start, length)));
      } else if (currentName.equals("parentLineNumber") && itemPos==2) {
       product.setParentLineNumber(Integer.parseInt(new String(ch, start, length)));
      } else if (currentName.equals("displayLineNumber") && servicePos==2 && itemPos==3) {
       service.setDisplayLineNumber(Integer.parseInt(new String(ch, start, length)));
      } else if (currentName.equals("lineNumber") && servicePos==2 && itemPos==3) {
       service.setLineNumber(Integer.parseInt(new String(ch, start, length)));
      } else if (currentName.equals("serviceName") && servicePos==2 && itemPos==3) {
       service.setServiceName(new String(ch, start, length));
      } else if (currentName.equals("serviceDescription") && servicePos==2 && itemPos==3) {
       service.setServiceDescription(new String(ch, start, length));

  • How to parse XML for internal table

    hi guys, I would like to know how to parse xml for an internal table. I explain myself.
    Let's say you have a purchase order form where you have header data & items data. In my interactive form, the user can change the purchase order quantity at the item level. When I received back the pdf completed by mail, I need to parse the xml and get the po qty that has been entered.
    This is how I do to get header data from my form
    lr_ixml_node = lr_ixml_document->find_from_name( name = ''EBELN ).
    lv_ebeln = lr_ixml_node->get_value( ).
    How do we do to get the table body??
    Should I used the same method (find_from_name) and passing the depth parameter inside a do/enddo?
    thanks
    Alexandre Giguere

    Alexandre,
    Here is an example. Suppose your internal table is called 'ITEMS'.
    lr_node = lr_document->find_from_name('ITEMS').
    lv_num_of_children = lr_node->num_children( ).
    lr_nodechild = lr_node->get_first_child( ).
    do lv_num_of_children times.
        lv_num_of_attributes = lr_nodechild->num_children( ).
        lr_childchild = lr_nodechild->get_first_child( ).
       do lv_num_of_attributes times.
          lv_value = lr_childchild->get_value( ).
          case sy-index.
             when 1.
               wa_item-field1 = lv_value
             when 2.
               wa_item-field2 = lv_value.
          endcase.
          lr_childchild = lr_childchild->get_next( ).
       enddo.
       append wa_item to lt_item.
       lr_nodechild = lr_nodechild->get_next( ).
    enddo.

  • Set XML attribute from SetValue using Xpath

    Is there a trick to assigning a value to an attribute of an element in an XML variable using XPATH inside a setValue activity?  When I try something like
    Location
    /process_var/xml_var/test/@ID
    Expression:
    /process_var/test_value
    it complains about the @ sign in the location assignment.  I seem to be able to retrieve attributes just fine.

    Still having this issue.
    If I have an XML process variable which currently contains
    <Document>
        <Title />
        <Author />
        <Date />
    </Document>
    Try this, it fails.
    Location: /process_data/xml/Document/@ID
    Expression: 54
    Try this, it works.
    Location: /process_data/xml/Document/ID
    Expression: 54
    Now, alter the XML by adding an ID attribute
    <Document ID="">
        <Title />
        <Author />
        <Date />
    </Document>
    Try this, it works, where it failed earlier.
    Location: /process_data/xml/Document/@ID
    Expression: 54
    It appears to me, you can ADD a new node, but you can't ADD an attribute

  • Accessing documents in xml db in browser using xpath not returning results

    I have loaded the purchaseorder documents and schema (from Oracle Magazine article (Mar/Apr 2003) "From XML to Storage and Back" article.
    I am able to access the LineItems element of the purchaseorder document using:
    http://localhost:8080/oradb/SCOTT/PURCHASEORDER/ROW/PurchaseOrder[Reference="ADAMS-20011127121040988PST"]/LineItems
    However, I cannot access the indivicual LineItem elements using the ItemNumber attribute:
    http://localhost:8080/oradb/SCOTT/PURCHASEORDER/ROW/PurchaseOrder[Reference="ADAMS-20011127121040988PST"]/LineItems/LineItem[@ItemNumber="2"]
    I get the following result:
    <?xml version="1.0"?>
    <ERROR>ORA-00904::invalid identifier</ERROR>
    I need to be able to use this and other xpath statements to extract elements from my document. Any suggestions?

    I'm including a sample purchase order:
    <?xml version="1.0" ?>
    - <PurchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://lisdev4db:8080/home/SCOTT/xsd/purchaseOrder.xsd">
    <Reference>WARD-20011127121040947PST</Reference>
    - <Actions>
    - <Action>
    <User>BLAKE</User>
    </Action>
    </Actions>
    <Reject />
    <Requestor>Stephen B. Ward</Requestor>
    <User>WARD</User>
    <CostCenter>S30</CostCenter>
    - <ShippingInstructions>
    <name>Stephen B. Ward</name>
    <address>1200 East Forty Seventh Avenue New York NY 10024 USA</address>
    <telephone>212 555 1212</telephone>
    </ShippingInstructions>
    <SpecialInstructions>Ground</SpecialInstructions>
    - <LineItems>
    - <LineItem ItemNumber="1">
    <Description>I Know Where I'm Going</Description>
    <Part Id="037429154427" UnitPrice="39.95" Quantity="2" />
    </LineItem>
    - <LineItem ItemNumber="2">
    <Description>The Last Wave</Description>
    <Part Id="037429161920" UnitPrice="29.95" Quantity="4" />
    </LineItem>
    - <LineItem ItemNumber="3">
    <Description>The Seven Samurai</Description>
    <Part Id="037429121726" UnitPrice="39.95" Quantity="2" />
    </LineItem>
    - <LineItem ItemNumber="4">
    <Description>Unbearable Lightness Of Being</Description>
    <Part Id="037429140222" UnitPrice="29.95" Quantity="4" />
    </LineItem>
    - <LineItem ItemNumber="5">
    <Description>Summertime</Description>
    <Part Id="037429130728" UnitPrice="29.95" Quantity="4" />
    </LineItem>
    - <LineItem ItemNumber="6">
    <Description>The Naked Kiss</Description>
    <Part Id="037429125823" UnitPrice="39.95" Quantity="4" />
    </LineItem>
    - <LineItem ItemNumber="7">
    <Description>Chihuly Over Venice</Description>
    <Part Id="037429141229" UnitPrice="29.95" Quantity="3" />
    </LineItem>
    - <LineItem ItemNumber="8">
    <Description>Written on the Wind</Description>
    <Part Id="715515011525" UnitPrice="29.95" Quantity="4" />
    </LineItem>
    - <LineItem ItemNumber="9">
    <Description>High and Low</Description>
    <Part Id="037429130322" UnitPrice="39.95" Quantity="2" />
    </LineItem>
    - <LineItem ItemNumber="10">
    <Description>Brief Encounter</Description>
    <Part Id="037429150726" UnitPrice="39.95" Quantity="2" />
    </LineItem>
    - <LineItem ItemNumber="11">
    <Description>Kwaidan</Description>
    <Part Id="037429152027" UnitPrice="29.95" Quantity="4" />
    </LineItem>
    - <LineItem ItemNumber="12">
    <Description>Withnail & I</Description>
    <Part Id="715515012225" UnitPrice="29.95" Quantity="1" />
    </LineItem>
    - <LineItem ItemNumber="13">
    <Description>Branded to Kill</Description>
    <Part Id="037429136225" UnitPrice="29.95" Quantity="2" />
    </LineItem>
    - <LineItem ItemNumber="14">
    <Description>The Hidden Fortress</Description>
    <Part Id="037429135129" UnitPrice="29.95" Quantity="2" />
    </LineItem>
    - <LineItem ItemNumber="15">
    <Description>The Most Dangerous Game</Description>
    <Part Id="037429137321" UnitPrice="24.95" Quantity="3" />
    </LineItem>
    - <LineItem ItemNumber="16">
    <Description>All That Heaven Allows</Description>
    <Part Id="715515011426" UnitPrice="39.95" Quantity="2" />
    </LineItem>
    - <LineItem ItemNumber="17">
    <Description>The Third Man</Description>
    <Part Id="037429141625" UnitPrice="39.95" Quantity="3" />
    </LineItem>
    - <LineItem ItemNumber="18">
    <Description>For All Mankind</Description>
    <Part Id="037429139523" UnitPrice="39.95" Quantity="3" />
    </LineItem>
    - <LineItem ItemNumber="19">
    <Description>Charade</Description>
    <Part Id="037429139424" UnitPrice="39.95" Quantity="2" />
    </LineItem>
    - <LineItem ItemNumber="20">
    <Description>Picnic at Hanging Rock</Description>
    <Part Id="037429126325" UnitPrice="29.95" Quantity="3" />
    </LineItem>
    - <LineItem ItemNumber="21">
    <Description>Christmas Glory From Westminster: An Evening of Christmas Music, Readings and Poetry</Description>
    <Part Id="037429161326" UnitPrice="19.95" Quantity="1" />
    </LineItem>
    - <LineItem ItemNumber="22">
    <Description>Samurai Three: Duel at Ganryu Island</Description>
    <Part Id="037429125625" UnitPrice="29.95" Quantity="3" />
    </LineItem>
    - <LineItem ItemNumber="23">
    <Description>Nanook of the North</Description>
    <Part Id="715515009829" UnitPrice="29.95" Quantity="3" />
    </LineItem>
    - <LineItem ItemNumber="24">
    <Description>My Man Godfrey</Description>
    <Part Id="715515011921" UnitPrice="39.95" Quantity="2" />
    </LineItem>
    - <LineItem ItemNumber="25">
    <Description>Discreet Charm of Bourgeoisie</Description>
    <Part Id="037429154625" UnitPrice="39.95" Quantity="1" />
    </LineItem>
    - <LineItem ItemNumber="26">
    <Description>The Seventh Seal</Description>
    <Part Id="037429124529" UnitPrice="39.95" Quantity="1" />
    </LineItem>
    - <LineItem ItemNumber="27">
    <Description>The Blob</Description>
    <Part Id="715515011129" UnitPrice="39.95" Quantity="3" />
    </LineItem>
    </LineItems>
    </PurchaseOrder>

  • Parse xml for conky

    I'd like to capture two key outputs and have them displayed in conky.  On my system, GPU load and GPU memory usage are available from the nvidia-smi program.  I can output in xml format which I'd like to parse and harvest to display in conky.  I can brute-force myself through it via grep and sed statements, but I'm looking for some suggestions from more knowledgeable people to do this in a minimal way.  For example, only run the program once, and harvest all data.  My current solution runs twice.
    Example output:
    $ nvidia-smi -a -x
    <?xml version="1.0" ?>
    <!DOCTYPE nvsmi_log SYSTEM "./nvsmi.dtd">
    <nvsmi_log>
    <timestamp>Mon Dec 6 17:48:50 2010</timestamp>
    <driver_version>260.19.21</driver_version>
    <gpu id="0">
    <prod_name>GeForce 8400 GS</prod_name>
    <pci_device_id>6e410de</pci_device_id>
    <pci_location_id>0:1:0</pci_location_id>
    <serial>2648101198649</serial>
    <display>Connected</display>
    <temp>43 C</temp>
    <utilization>
    <gpu_util>0%</gpu_util>
    <memory_util>8%</memory_util>
    </utilization>
    </gpu>
    </nvsmi_log>
    [facade@simplicity ~]$ nvidia-smi -a -x
    <?xml version="1.0" ?>
    <!DOCTYPE nvsmi_log SYSTEM "./nvsmi.dtd">
    <nvsmi_log>
    <timestamp>Mon Dec 6 17:49:30 2010</timestamp>
    <driver_version>260.19.21</driver_version>
    <gpu id="0">
    <prod_name>GeForce 8400 GS</prod_name>
    <pci_device_id>6e410de</pci_device_id>
    <pci_location_id>0:1:0</pci_location_id>
    <serial>2648101198649</serial>
    <display>Connected</display>
    <temp>43 C</temp>
    <utilization>
    <gpu_util>5%</gpu_util>
    <memory_util>10%</memory_util>
    </utilization>
    </gpu>
    </nvsmi_log>
    Or it might be better not to go to xml which I can do by omitting the -x switch:
    $ nvidia-smi -a
    ==============NVSMI LOG==============
    Timestamp : Mon Dec 6 17:50:06 2010
    Driver Version : 260.19.21
    GPU 0:
    Product Name : GeForce 8400 GS
    PCI Device/Vendor ID : 6e410de
    PCI Location ID : 0:1:0
    Board Serial : 2648101198649
    Display : Connected
    Temperature : 43 C
    Utilization
    GPU : 0%
    Memory : 8%
    Thanks!
    Last edited by graysky (2014-11-03 08:39:36)

    Damn, my memory is truly shit.  Thanks, ST.  The awk syntax is still foreign to me.  How would I segregate the RAM usage from the GPU usage?  I think conky needs the output to be unique for each one in their own script.
    EDIT: Got it.
    # Swap Usage:$color $swapperc%${color lightgrey}
    # the ${template x x x} command uses /sys/bus/platform/devices
    # for this to work you need both lm-sensors and hddtemp
    # get both from main repos
    # set to yes if you want Conky to be forked in the background
    background no
    own_window yes
    own_window_type override
    own_window_transparent yes
    own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
    out_to_console no
    # Use Xft?
    use_xft yes
    # Xft font when Xft is enabled
    #xftfont Bitstream Vera Sans Mono:size=8
    xftfont monospace:size=8
    #xftalpha 0.8
    # Update interval in seconds
    update_interval 2
    # Create own window instead of using desktop (required in nautilus)
    own_window yes
    # Use double buffering (reduces flicker, may not work for everyone)
    double_buffer yes
    # Minimum size of text area
    #minimum_size 250 5
    maximum_width 258
    # Draw shades?
    draw_shades no
    # Draw outlines?
    draw_outline no
    # Draw borders around text
    draw_borders no
    # Stippled borders?
    stippled_borders 10
    # border margins
    #border_margin 4
    # border width
    border_width 1
    # Default colors and also border colors
    default_color white
    default_shade_color white
    default_outline_color white
    # Text alignment, other possible values are commented
    #alignment top_left
    #minimum_size 10 10
    #alignment top_right
    alignment bottom_left
    #alignment bottom_right
    # Gap between borders of screen and text
    gap_x 12
    gap_y 37
    # Add spaces to keep things from moving about? This only affects certain objects.
    use_spacer left
    # Subtract file system buffers from used memory?
    no_buffers yes
    # set to yes if you want all text to be in uppercase
    uppercase no
    default_bar_size 120 6
    TEXT
    ${color #6495ed}$nodename$color - $sysname $kernel on $machine
    ${color lightgrey}Uptime:$color $uptime ${color lightgrey}- Load:$color $loadavg${color lightgrey}
    $color$stippled_hr${color lightgrey}
    Processes: $processes Running:$color$running_processes
    ${color}Name PID CPU% MEM%
    ${color #6495ed} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
    ${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
    ${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
    ${color}Mem usage
    ${color #6495ed} ${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
    ${color lightgrey} ${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
    ${color lightgrey} ${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}
    $color$stippled_hr${color lightgrey}
    ${color #6495ed}CPU0: ${color lightgrey}Intel Xeon X3360 @ $color${freq_g} GHz${color lightgrey}
    ${color #6495ed}CPU Fan: $color${platform it87.656 fan 1}${color grey} RPM @ $color${execi 8 cat /sys/class/hwmon/hwmon4/device/pwm1}
    ${color #6495ed}RAM:$color$mem ($memperc%) ${color lightgrey}of 8.0 GB
    ${color black}${cpugraph 35,200 5000a0 6495ed}${color white} ${cpugauge 35}${color lightgrey}
    ${color lightgrey}Core0:$color${platform coretemp.0 temp 1} °C${color grey} @$color ${cpu cpu1}% ${alignr}${cpubar cpu1 6,120}
    ${color lightgrey}Core1:$color${platform coretemp.1 temp 1} °C${color grey} @$color ${cpu cpu2}% ${alignr}${cpubar cpu2 6,120}
    ${color lightgrey}Core2:$color${platform coretemp.2 temp 1} °C${color grey} @$color ${cpu cpu3}% ${alignr}${cpubar cpu3 6,120}
    ${color lightgrey}Core3:$color${platform coretemp.3 temp 1} °C${color grey} @$color ${cpu cpu4}% ${alignr}${cpubar cpu4 6,120}${color grey}
    ${color grey}CPU:$color${platform it87.656 temp 1} °C ${color grey} ${color grey} M/B:$color ${platform it87.656 temp 2} °C ${color grey} sda:$color ${execi 300 sudo hddtemp /dev/sda | cut -c34-35} °C
    $color$stippled_hr${color lightgrey}
    ${color #6495ed}GPU0:${color lightgrey} nVidia 8800 GS (${nvidia gpufreq}/${nvidia memfreq}) MHz
    ${color #6495ed}VRAM:${color lightgrey} ${exec nvidia-smi -a | grep -A 2 "Utilization" | tr -d % | grep "Memory" | awk '{print $3}'}% of 512MiB
    ${color #6495ed}GPU0:${color lightgrey}$color${nvidia temp} °C @ ${exec nvidia-smi -a | grep -A 2 "Utilization" | tr -d % | grep "GPU" | awk '{print $3}'}% ${execbar nvidia-smi -a | grep -A 2 "Utilization" | tr -d % | grep "Memory" | awk '{print $3}'}
    $color$stippled_hr${color lightgrey}
    ${color lightgrey}RAMDisk: ${color }${fs_used_perc /dev/shm} % ${fs_bar /dev/shm 6,120}
    Last edited by graysky (2010-12-07 00:54:15)

  • Parse xml for font / paragraph styling

    Has anyone tried to understand the XML representation of font style (or as I believe it is defined in the XML, "paragraphstyle")? I am having trouble getting all the lookups. I get multiple results. I am not an expert on XML. Is "property-map" a term that is unique to this XML definition, or is their a standard way to look up values via an XML property-map.
    I am wondering if I need a combination of styletheetID, paragraphstyleID and parent-ident, just to get a single lookup val?
    I have pasted what my return results look like:
    <sf:paragraphstyle sfa:ID="SFWPParagraphStyle-94" sf:parent-ident="titleHeadlineParagraphStyleID">
    <sf:property-map/>
    </sf:paragraphstyle>
    <sf:paragraphstyle sfa:ID="SFWPParagraphStyle-94" sf:parent-ident="slideNotesParagraphStyleID">
    <sf:property-map/>
    </sf:paragraphstyle>
    <sf:paragraphstyle sfa:ID="SFWPParagraphStyle-94" sf:parent-ident="shapeParagraphStyleID">
    <sf:property-map>
    <sf:fontName>
    <sf:string sfa:string="CopperplateGothic-Bold"/>
    </sf:fontName>
    <sf:fontColor>
    <sf:color xsi:type="sfa:calibrated-white-color-type" sfa:w="0.90196079015731812" sfa:a="1"/>
    </sf:fontColor>
    <sf:fontSize>
    <sf:number sfa:number="18" sfa:type="q"/>
    </sf:fontSize>
    </sf:property-map>
    </sf:paragraphstyle>
    <sf:paragraphstyle sfa:ID="SFWPParagraphStyle-94" sf:parent-ident="level1HeadlineParagraphStyleID">
    <sf:property-map/>
    </sf:paragraphstyle>
    <sf:paragraphstyle sfa:ID="SFWPParagraphStyle-94" sf:parent-ident="shapeParagraphStyleID">
    <sf:property-map>
    <sf:fontName>
    <sf:string sfa:string="Corbel-Bold"/>
    </sf:fontName>
    <sf:fontColor>
    <sf:color xsi:type="sfa:calibrated-white-color-type" sfa:w="0.90196079015731812" sfa:a="1"/>
    </sf:fontColor>
    <sf:fontSize>
    <sf:number sfa:number="18" sfa:type="q"/>
    </sf:fontSize>
    </sf:property-map>
    </sf:paragraphstyle>
    <sf:paragraphstyle sfa:ID="SFWPParagraphStyle-94" sf:parent-ident="shapeParagraphStyleID">
    <sf:property-map>
    <sf:fontName>
    <sf:string sfa:string="Futura-Medium"/>
    </sf:fontName>
    <sf:alignment/>
    <sf:fontColor>
    <sf:color xsi:type="sfa:calibrated-white-color-type" sfa:w="0.90196079015731812" sfa:a="1"/>
    </sf:fontColor>
    <sf:fontSize/>
    </sf:property-map>
    </sf:paragraphstyle>
    I should also note another weird behavior... when I do a "find" within the text application I only get two results for "SFWPParagraphStyle-94", one for the paragraph where it is used, and one in the stylesheet section where it is defined (ie. the return result that I expect).

    I am trying to decipher what the current text formatting of a shape is. I am parsing through the slides, parsing through the shapes of a slide, and am now trying to lookup/extract the formatting of the text that is inside the shape.
    which looks like this in my test file:
    <sf:p sf:style="SFWPParagraphStyle-94">Centered, has a font override<sf:br/></sf:p>
    <sf:p sf:style="SFWPParagraphStyle-94">and line break</sf:p>
    With regards to the post above, I was making a rookie error... I was using:
    xml.blablabla.paragraphstyle.(@ID="SFWPParagraphStyle-94");
    instead of
    xml.blablabla.paragraphstyle.(@ID=="SFWPParagraphStyle-94");
    .... so that obviously now clears that up.... totally.. duh
    Now I am just trying to continue to look up all the inheritance formatting... which to me, at this point is not that straight forward. So I would prefer to leave this thread open as to "how to parse for text formatting"
    So far I am:
    getting the stylesheet-ref
    looking up the paragraphStyle
    which then points to the master-slide
    ....

  • Fetching xml node nth value using Xpath

    HI Experts ,
    with reference to below question, i have one more doubt.
    https://social.msdn.microsoft.com/Forums/en-US/f894e5e2-8926-4604-9171-616da3f00cd7/xpath-to-fetch-value-in-flatfile-schema?forum=biztalkgeneral
    I used below xpath to fetch nth value of full repeating message nodes
    indexStr = System.Convert.ToString(index);DATE=xpath(In_FF, "string(//*[local-name() = 'Details']["+indexStr+"])/*[local-name()='DATE'])");index=index + 1;
    and i got below error, can any help me in this?
    Exception thrown from: segment 2, progress 43
    Inner exception: 'string(//*[local-name() = 'Details'][1])/*[local-name()='DATE'])' has an invalid token.
    Exception type: XPathException
    Source: System.Xml
    Target Site: MS.Internal.Xml.XPath.AstNode ParseXPathExpresion(System.String)
    The following is a stack trace that identifies the location where the exception occured

    your XPATH expression is WRONG.
    it should be
    DATE=xpath(In_FF,
    "string(//*[local-name() = 'Details']["+indexStr+"]/*[local-name()='DATE'])");
    There is NO ")" after ["+indexStr+"].
    The more reliable way is to use a string variable and use the System.String.Format() call as below
    xPathExpr = System.String.Format("string(//*[local-name() = 'Details'][{0}]/*[local-name()='DATE'])", index);
    DATE=xpath(In_FF, xPathExpr);
    The "invalid token" is because of the mismatched ")" in your XPATH Expression.
    Regards.

  • Very high parse times for query rewrite using cube materialized views

    We recently upgraded to version 11.2.0.2 (both AWM and Oracle database server). We are using cube materialized views with query rewrite enabled. Some observations of changes that took place when we rebuilt all the dimensions and cubes in this version:
    1. Queries against the base tables take about 35 seconds to parse. Then they execute in a tenth of a second. Even simple queries that just get a sum of the amount from the fact table (which is joined to all the dimensions) takes that long to parse. Once parsed, the queries fly.
    2. I noticed that the materialized views used to use grouping sets in the group by clause in version 11.2.0.1, but now they use group by rollup, rollup, rollup...
    If we disable query rewrite on the MV or for my session, parse times drop to less than a second. Ideas?

    There does appear to be a slow down in parse times between 11.1.0.7 and 11.2. We are still investigating this, but in the meantime here is a way to force the code in 11.2 to generate a GROUPING SETS clause instead of the new ROLLUP syntax.
    The trick is to create a dummy hierarchy containing only the leaf level. This is necessary for all dimensions that currently have a single hierarchy. As a simple example I created a dimension, PROD, with three levels, A, B, and C, in a single hierarchy. I then created a one dimensional cube, PC. Here is the SELECT statement for the MV in 11.2. Note the ROLLUP clause in the GROUP BY.
    SELECT
      GROUPING_ID(T3."CLASS_ID", T3."FAMILY_ID", T3."ITEM_ID")  SYS_GID,
      (CASE GROUPING_ID(T3."CLASS_ID", T3."FAMILY_ID", T3."ITEM_ID")
       WHEN 3
       THEN TO_CHAR(('A_' || T3."CLASS_ID") )
       WHEN 1
       THEN TO_CHAR(('B_' || T3."FAMILY_ID") )
       ELSE TO_CHAR(('C_' || T3."ITEM_ID") )  END)     "PROD",
      T3."CLASS_ID" "D1_PROD_A_ID",
      T3."FAMILY_ID" "D1_PROD_B_ID",
      T3."ITEM_ID" "D1_PROD_C_ID",
      SUM(T2."UNIT_PRICE")     "PRICE",
      COUNT(T2."UNIT_PRICE")  "COUNT_PRICE",
      COUNT(*)  "SYS_COUNT"
    FROM
      GLOBAL."PRICE_AND_COST_FACT" T2,
      GLOBAL."PRODUCT_DIM" T3
    WHERE
      (T3."ITEM_ID" = T2."ITEM_ID")
    GROUP BY
      (T3."CLASS_ID") ,
      ROLLUP ((T3."FAMILY_ID") , (T3."ITEM_ID") )Next I modified the dimension to add a new hierarchy, DUMMY, containing just the leaf level, C. Once I have mapped the new level and re-enabled MVs, I get the following formulation.
    SELECT
      GROUPING_ID(T3."CLASS_ID", T3."FAMILY_ID", T3."ITEM_ID")  SYS_GID,
      (CASE GROUPING_ID(T3."CLASS_ID", T3."FAMILY_ID", T3."ITEM_ID")
       WHEN 3
       THEN ('A_' || T3."CLASS_ID")
       WHEN 1
       THEN ('B_' || T3."FAMILY_ID")
       WHEN 0
       THEN ('C_' || T3."ITEM_ID")
       ELSE NULL END)  "PROD",
      T3."CLASS_ID" "D1_PROD_A_ID",
      T3."FAMILY_ID" "D1_PROD_B_ID",
      T3."ITEM_ID" "D1_PROD_C_ID",
      SUM(T2."UNIT_PRICE")     "PRICE",
      COUNT(T2."UNIT_PRICE")  "COUNT_PRICE",
      COUNT(*)  "SYS_COUNT"
    FROM
      GLOBAL."PRICE_AND_COST_FACT" T2,
      GLOBAL."PRODUCT_DIM" T3
    WHERE
      (T3."ITEM_ID" = T2."ITEM_ID")
    GROUP BY
      GROUPING SETS ((T3."CLASS_ID") , (T3."FAMILY_ID", T3."CLASS_ID") , (T3."ITEM_ID", T3."FAMILY_ID", T3."CLASS_ID") )This puts things back the way they were in 11.1.0.7 when the GROUPING SETS clause was used in all cases. Note that the two queries are logically equivalent.

  • Parse XML

    how is possible to parse a XML file without using:
    javax.xml.parsers.*
    org.w3c.dom.*
    org.xml.sax.*
    thanks...

    OK, so why are you asking the question?
    Java platforms (version >= 1.4) come with a SAX based XML parser.
    SAX XML parsers are freely available as components for use with previous versions.
    Alternatively, if you don't want to use SAX, you can download one of the freely available pull-parsers.
    If you want to write your own, you can read the spec and write a parser for the grammar. To do that correctly, handiling namespaces and parsed entities is a few weeks work for a good programmer, who understands XML and parsing. In general, this is a waste of time, as the freely available software is of fairly high quality and robustness.
    If your application requires XML for compatability, then use one of the technologies you say you want to avoid, or one of the existing alternatives.
    Pete

  • Flash Player 10 removes HTML encoding in CDATA when parsing XML

    I have an application that was written with Flash Professional 8/AS2 and it parses XML for rendering dynamic media content. The XML pulls text with HTML markup out of CDATA sections and places them into an html enabled text field. Everything has worked wonderfully until Flash Player 10.
    Now, if we use html escape characters for greater than or less than symbols, they are being decoded by the xml parser.
    Here's my example CDATA section:
    Here <u>we</u> go: This &#60;node&#62; &lt;works&gt; 
    when I grab its value using nodeValue or toString, the results are different from Flash Player 9 to 10. Here's what I'm getting:
    node.nodeValue (Flash Player 9):
    Here <u>we</u> go: This &#60;node&#62; <works>
    node.nodeValue (Flash Player 10):
    Here <u>we</u> go: This <node> <works>
    node.toString (Flash Player 9):
    Here <u>we</u> go: This &#60;node&#62; &lt;works&gt;
    node.toString (Flash Player 10):
    Here <u>we</u> go: This <node> <works>
    In Flash 10, if I escape the ampersand, it will work, but this doesn't work in 9. for example, the following works in 10:
    <![CDATA[Here <u>we</u> go: This &amp;#60;node&amp;#62; &amp;lt;works&amp;gt;]]>
    This all happens before I assign it to a text field. How do I keep the parser from destroying my escaped characters in Flash 10? Do I just need to drop support for Flash Player 9 and go for what works in 10, or is there a solution for both?
    Message was edited by: Xygar

    I'm not an action script programmer. I'm just trying to fix some code written like 3 years ago. So I think I am wrong about where this problem is coming from.
    The original developer actually set up a class to load a remote xml file via sendAndLoad on a LoadVars object. It passes an object with an onData delegate set that passes the event object to an xml parsing method.
    the parsing method looks like this:
         private function parseXml(eventObj:Object){
              if(eventObj != undefined)
                   try
                        //ExternalInterface.call("logMessage", eventObj.toString());
                        _xmlDoc.parseXML(eventObj.toString());
                        _xmlDoc.loaded = true;
                        _xmlDoc.onLoad(true);
                   catch(ex)
                        _xmlDoc.onLoad(false);
              else
                   _xmlDoc.onLoad(false);
    I added the ExternalInterface call so that I could log the stuff out in javascript (since I'm not sure how to debug this app).
    _xmlDoc is defined as: private var _xmlDoc:XML;
    The eventObj receives the xml string and then passes it to the parseXML thing. Here's the odd part. In Flash Player 10, if I comment out my ExternalInterface call, the xml string has the escaped character decoded before it gets to the parser.
    However, if I uncomment my ExternalInterface call, it logs the escaped strings as i would expect, but the parser gets the correct formatting this time! Suddenly it all works.
    I really wish I had an AS2 programmer on campus still....

  • How do i Parsing xml

    This how my customers xml is coming across and can not
    change.
    <month name="January">
    <day>
    <date>01</date>
    <name>Thursday</name>
    <time>12:03 PM</time>
    <comment>It is a hot day</comment>
    </day>
    <day>
    <date>05</date>
    <name>Monday</name>
    <time>09:28 AM</time>
    <comment>Another hot day</comment>
    </day>
    </month>
    The above data structure uses a new node for each bit of core
    information. It is well laid out and very readable by humans,
    however a better structure exists when using Flash. The data
    structure below makes more use of the attributes feature, speeding
    the parsing process up. It takes longer for Flash to read 6
    separate nodes, than it does 6 attributes of a node. The data
    structure below is suited better for use with Flash.
    How do I get it formated like this?
    <month name="January">
    <day date="01" name="Thursday" time="12:03 PM" comment="It
    is a hot day" />
    <day date="05" name="Monday" time="09:28 AM"
    comment="Another hot day" />
    </month>

    Hello again,
    Sorry, I thought you wanted to know how to parse XML for this
    structure
    <month name="January">
    <day date="01" name="Thursday" time="12:03 PM" comment="It
    is a hot day" />
    <day date="05" name="Monday" time="09:28 AM"
    comment="Another hot day" />
    </month>
    This is the one that the code I wrote is using. I think
    you're loading in the other one. Doesn't matter - I've included the
    for loop for both structures below so that you can try it with
    both.

  • SSMS 2012:FOR XML PATH Using XPath Node Tests-Columnn name 'test()' contains an invalid XML identifier as required by FOR XML?

    Hi all,
    I am learning XPATH and XQUERY from the Book "Pro T-SQL 2008 Programmer's Guide" written by Michael Coles, (published by apress). I copied the Code Listing 12-8 FOR XML PATH Using XPath Node Tests (listed below) and executed it in my
    SQL Server 2012 Management Studio:
    --Coles12_8.sql // saved in C:/Documemnts/SQL Server Management Studio
    -- Coles Listing 12-8 FOR XML PATH Using XPATH Node Tests
    -- Retrieving Name and E-mail Addresses with FOR XML PATH in AdvantureWorks
    -- 16 March 2015 0935 AM
    USE AdventureWorks;
    GO
    SELECT
    p.NameStyle AS "processing-instruction(nameStyle)",
    p.BusinessEntityID AS "Person/@ID",
    p.ModifiedDate AS "comment()",
    pp.PhoneNumber AS "test()",
    FirstName AS "Person/Name/First",
    MiddleName AS "Person/Name/Middle",
    LastName AS "Person/Name/Last",
    EmailAddress AS "Person/Email"
    FROM Person.Person p
    INNER JOIN Person.EmailAddress e
    ON p.BusinessEntityID = e.BusinessEntityID
    INNER JOIN Person.PersonPhone pp
    ON p.BusinessEntityID = pp.BusinessEntityID
    FOR XML PATH;
    I got the following error message:
    Msg 6850, Level 16, State 1, Line 2
    Column name 'test()' contains an invalid XML identifier as required by FOR XML; '('(0x0028) is the first character at fault.
    I have no ideas why I got this error message.  Please kindly help and advise me how to resolve this error.
    Thanks in advance,  Scott Chang

    Hi Michelle, Thanks for your nice response.
    I corrected the mistake and executed the revised code. It worked nicely.
    I just have one question to ask you about the appearance of the xml output of my Co;les12_8.sql:
    <row>
    <?nameStyle 0?>
    <Person ID="1" />
    <!--2003-02-08T00:00:00-->697-555-0142<Person><Name><First>Ken</First><Middle>J</Middle><Last>Sánchez</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="2" />
    <!--2002-02-24T00:00:00-->819-555-0175<Person><Name><First>Terri</First><Middle>Lee</Middle><Last>Duffy</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="3" />
    <!--2001-12-05T00:00:00-->212-555-0187<Person><Name><First>Roberto</First><Last>Tamburello</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="4" />
    <!--2001-12-29T00:00:00-->612-555-0100<Person><Name><First>Rob</First><Last>Walters</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="5" />
    <!--2002-01-30T00:00:00-->849-555-0139<Person><Name><First>Gail</First><Middle>A</Middle><Last>Erickson</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="6" />
    <!--2002-02-17T00:00:00-->122-555-0189<Person><Name><First>Jossef</First><Middle>H</Middle><Last>Goldberg</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="7" />
    <!--2003-03-05T00:00:00-->181-555-0156<Person><Name><First>Dylan</First><Middle>A</Middle><Last>Miller</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="8" />
    <!--2003-01-23T00:00:00-->815-555-0138<Person><Name><First>Diane</First><Middle>L</Middle><Last>Margheim</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="9" />
    <!--2003-02-10T00:00:00-->185-555-0186<Person><Name><First>Gigi</First><Middle>N</Middle><Last>Matthew</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="10" />
    <!--2003-05-28T00:00:00-->330-555-2568<Person><Name><First>Michael</First><Last>Raheem</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    <?nameStyle 0?>
    <Person ID="11" />
    <!--2004-12-29T00:00:00-->719-555-0181<Person><Name><First>Ovidiu</First><Middle>V</Middle><Last>Cracium</Last></Name><Email>[email protected]</Email></Person></row>
    <row>
    I feel this xml output is not like the regular xml output.  Do you know why it is diffrent from the regular xml xml output?  Please comment on this matter.
    Thanks,
    Scott Chang
    What do you mean by regular xml document? Are you referring to fact that its missing a root element? if yes it can be added as below
    USE AdventureWorks;
    GO
    SELECT
    p.NameStyle AS "processing-instruction(nameStyle)",
    p.BusinessEntityID AS "Person/@ID",
    p.ModifiedDate AS "comment()",
    pp.PhoneNumber AS "text()",
    FirstName AS "Person/Name/First",
    MiddleName AS "Person/Name/Middle",
    LastName AS "Person/Name/Last",
    EmailAddress AS "Person/Email"
    FROM Person.Person p
    INNER JOIN Person.EmailAddress e
    ON p.BusinessEntityID = e.BusinessEntityID
    INNER JOIN Person.PersonPhone pp
    ON p.BusinessEntityID = pp.BusinessEntityID
    FOR XML PATH('ElementName'),ROOT('RootName');
    replace ElementName and RootName with whatever name you need to set for element as well as the root element
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Problem for using oracle xml parser v2 for 8.1.7

    My first posting was messed up. This is re-posting the same question.
    Problem for using oracle xml parser v2 for 8.1.7
    I have a sylesheet with
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">.
    It works fine if I refer this xsl file in xml file as follows:
    <?xml-stylesheet type="text/xsl" href="http://...../GN.xsl"?>.
    When I use this xsl in pl/sql package, I got
    ORA-20100: Error occurred while processing: XSL-1009: Attribute 'xsl:version' not found in 'xsl:stylesheet'.
    After I changed name space definition to
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> in xsl file, I got
    ORA-20100: Error occurred while processing: XSL-1019: Expected ']' instead of '$'.
    I am using xml parser v2 for 8.1.7
    Can anyone explain why it happens? What is the solution?
    Yi

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Steven Muench ([email protected]):
    Element's dont have text content, they [b]contain text node children.
    So instead of trying to setNodeValue() on the element, construct a Text node and use the appendChild method on the element to append the text node as a child of the element.<HR></BLOCKQUOTE>
    Steve,
    We are also creating an XML DOM from java and are having trouble getting the tags created as we want. When we use XMLText it creates the tag as <tagName/>value rather than <tagName>value</tagName>. We want separate open and close tags. Any ideas?
    Lori

  • Using XPath for DOM traversal

    This question falls into the category of 'I know it's possible, I just need to find the idom in Java'.
    I'm coming from a MSFT world were the DOM-centric model of XML processing makes heavy use of XPATH for node selection. Basically using the method element.selectNodes(XPathExpresson) allows one to quickly extract the relevant subset of the parsed tree in the DOM as a nodeList. I've become accustomed to using XML for all strucutured storage that doesn't require a full database.
    The W3C DOM Level 3 spec supports evaluateExpression() for this purpose, but I can't believe that Java developers are still using tree traversal waiting for the spec to be implemented. I suppose that I could use getNodesByTagName(), but this is a chainsaw, and I need a scalpel. Anyway, I'm trying to figure out how, exactly, this gets done in Java.
    I figure the following are possibilities:
    1) It's in JAXP and I missed it
    2) One or more of the XML parsers supports XPATH as an extention
    3) There's a common package that sits on top of the DOM Document.
    4) There's a standard way to apply and XSLT methods to the DOM document
    5) Something I've never thought of.
    This is a generalized problem for me, so I can't rely on object serialization, Java-XML data mapping, etc. Any guidance would be greatly appreciated.

    I've written a Config file reader for XML in java,
    and it extracts values using XPath. This is
    some of the code you'll need:
    imports:
    import javax.xml.transform.TransformerException;
    import org.w3c.dom.*;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.apache.xerces.parsers.DOMParser;
    import org.apache.xpath.XPathAPI;
    import org.apache.xpath.objects.*;
    Document doc=....;
    * returns a single DOM Node from the config file.
    public Node getNode(String xpath) throws ConfigException {
    try {
    return XPathAPI.selectSingleNode(doc, xpath);
    } catch (TransformerException e) {
    throw new ConfigException("Can't find '"+xpath+"' ("+e.getMessage()+")");

Maybe you are looking for

  • How to change the default position of context menu item? (C#)

    Hi, I have included a calendar context menu item with my Outlook Addin. But by default, its positioned at the last as shown in the picture below: I need a way to make it as the fourth item instead of last one. Also, I want set an icon for the same. H

  • Using Sony Bravia as display brightness issue

    I'm using a Mini as a media server, hooked up via HDMI to a recently purchased Sony Bravia TV. When watching video, the picture will automatically get brighter or darker -- but in the most annoying way possible. When watching a movie with a particula

  • Image Sequencing in Quick Time Pro

    Since upgrading to Snow Leopard I have been unable to get Quick Time Pro to created an Image Sequence. I'm wondering if this is an issue created by Quick Time Pro being moved to its new location in Snow Leopard. Can anyone, who's recently upgraded, t

  • Matching issue in Data Manager

    Hi All, We are having an issue where we have customer number maintained as both with and without leading zeroes like as 123 and 00123. If we run the matching strategy we get as None as it is considering those as different value. Is there some way so

  • How do I delete an item in the sidebar - iPhoto 11

    How do I delete an item on the iPhoto 11 sidebar?