XPath API woes

I'm trying to parse an XML document using the Actionscript 2
XPath API. In one place I am using this as my xpath:
presentation/content[@contentName='wellness']/section[@sectionName='Nutrition/Weight']'
It fails when I use a slash in the "sectionName" attribute,
when I remove the slash in the XML file and change the xpath
accordingly it works fine. This XML is being generated for me, so I
really have no choice in the matter, the slash has to stay. Is
there something I can do to get around this problem?

Mainly :
- Speed,
- Compact : 100Ko,
- Pluggable kit for custom node usage,
- JDK 1.1,
- Featuring like lowercase/uppercase for HTML.
Hope it replies,
A.Brillant

Similar Messages

  • XPath API getting Nodes

    Hi,
    My Data XML converted through Xstream
    <Data>
    <id>1</id>
    <name>Name</name>
    <DataList>
    <DataVO>
    <VoId>100</VoId>
    <value>Value1</value>
    <ProductList>
    <Product>
    <ProductId>P101</ProductId>
    <PName>Product Name1</PName>
    </Product>
    <Product>
    <ProductId>P102</ProductId>
    <PName>Product Name2</PName>
    </Product>
    </ProductList>
    </DataVO>
    <DataVO>
    <VoId>101</VoId>
    <value>Value2</value>
    <ProductList>
    <Product>
    <ProductId>P201</ProductId>
    <PName>Product NameX1</PName>
    </Product>
    <Product>
    <ProductId>P202</ProductId>
    <PName>Product NameX2</PName>
    </Product>
    </ProductList>
    </DataVO>
    </DataList>
    </Data>
    The Problem
    =========
    While I am maintaining the relationship parsing through XPath API , I am giving to fetch products as API path as "/Data/Datalist/DataVO/ProductList/Product/ProductId" to get the list of products, I can able to get the 4 Products NodeList, But I want to set the each products "VoId" , Like P101 related with 100, P102 related with 100, P201 related with 101, P202 related with 101. Any Sugesstions, parsing logics?

    Namespaces are not evaluated as XML constructs in XPath, but namespaces are required to be configured in the parser. Refer
    Parsing with the JDOM XPath Class
    http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html

  • Fast XPath API

    JXP is a Fast XPath 1.0 compliant API.
    Download :
    http://www.japisoft.com/jxpath/download/unregistered.zip
    Home :
    http://www.japisoft.com/jxpath
    Forum :
    http://www.japisoft.com/forum/index.php
    News :
    Cache support for the navigator (by default enabled)
    Fixed bug for simple expressions like 1+1
    Fixed bug for // usage
    A DOM document can be used rather than an Element
    Main features :
    * High performance full XPath 1.0 solution,
    * 25% faster than jaxen,
    * SAX - like event system,
    * Inner expression tree for fast multiple document evaluation,
    * Syntax error location and cause,
    * DOM support,
    * FastParser lightweight node support,
    * Customizable API with navigator, function libraries,
    * Plugin for each node type system,
    * Lower/Uppercase feature
    * Full samples with DOM,
    * Tested on 150 XPath expressions,
    * Benchmark tests included,
    * Package of 85 Ko
    * Open source for the registered version,
    * JDK1.1 and later compliant (tested on JDK1.1.8 and JDK1.4.1)
    A.Brillant
    http://www.japisoft.com

    Mainly :
    - Speed,
    - Compact : 100Ko,
    - Pluggable kit for custom node usage,
    - JDK 1.1,
    - Featuring like lowercase/uppercase for HTML.
    Hope it replies,
    A.Brillant

  • Memery leak in Xpath API (64 Bits) of Oracle_XDK C Components v10.1.0.3.0

    uname -a
    SunOS ans7135 5.10 Generic_118822-02 sun4u sparc SUNW,UltraAX-i2
    cc -V
    cc: Sun C 5.6 Patch 117551-05 2005/05/10
    I compiled XSLXPathSample.c with -xarch=v9 and LIB=-L$(TOP)/lib64 $(XDK_LIB) $(ORA_LIB) -ldl $(NET_LIB) -lm.
    Purify found there is a lot of memery leak from XmlXPathCreateCtx().
    There is no leak in 32 Bits.
    Please help me to find out the reason.
    Thank you very much.

    I encountered the same problems with binding date variables on Solaris. The SQLBindParamater would be successful for the date, but during the SQLExecute I always get this error:
    ORA-01483: invalid length for DATE or NUMBER bind variable
    I logged an official service request, and Oracle confirmed the problem. You can see it at bug 5241003. FYI, there is currently no estimated time for a fix.

  • C++ sample code using XPATH

    Need to navigate an XML and extract xml nodes using XPATH expressions in C++ Application.
    Please send us a C++ code sample using Oracle 9.2.0.3 XPATH API functions to extract an XML using XPATH expression.
    Thanks
    Shiva

    Hi,
    Where i can find this path "$XDK_HOME\xdk\demo\c\xslt"
    thanks in advance
    shashi.

  • XPath for Java

    Hi all,
    I have an xml and i would like to do some query to the xml.
    Is there any XPath API that i can use in java ?
    Currently using 1.4.2
    Is there any other recommendations?
    Thanks

    Xalan and Jaxen are two possibilities:
    http://xml.apache.org/xalan-j/
    http://jaxen.org/

  • XPATH sample code

    Hi ,
    Does Oracle 9.2.0 has XPATH API's?
    I need to use XPATH to extract data from an XML document.
    I searched over the net but I am not able to find usage of Oracle XPATH API's in c/c++ .
    Can anybody please provide me a code sample to use Oracle 9.2.0 XPAPTH API's.
    Thanks
    MRA

    In 10g, the sample code is included at:
    $XDK_HOME\xdk\demo\c\xslt

  • XPath Not Working (Namespace ?)

    I am not receiving any errors, but similair XPath in XMLSpy works...
    I have an XML document:
    <Results>
    <acc:Account xmlns:account="http://test/account" id="1">
    <acc:Name>Account Name 1</acc:Name>
    </acc:Account>
    <acc:Account xmlns:account="http://test/account" id="2">
    <acc:Name>Account Name 2</acc:Name>
    </acc:Account>
    </Results>
    When I use: "//Results" I get a a Node back
    When I use: //Results/acc:Account[@id=1], I get no results back and no errors
    To avoid namespace problems I used a StaticNamespaceResolver...
    My code:
    HashMap prefixes = new HashMap(1);
    String namespace = "http://test/account";
    prefixes.put("acc", namespace);
    try {
         XObject obj = XPathAPI.eval(RootNode, queryStr, new StaticPrefixResolverImpl(prefixes));
    NodeList nl = obj.nodelist();
    System.out.println("NodeList Length: " + nl.getLength());
    } catch (Exception ee) {
    System.out.println(ee);
    Thanks!

    Seems to me your problem is that you can't decide what prefix to use...
    Is it 'acc' or 'account' ?
    In your sample document, try:
    <Results>
    <acc:Account xmlns:acc="http://test/account" id="1">
    <acc:Name>Account Name 1</acc:Name>
    </acc:Account>
    <acc:Account xmlns:acc="http://test/account" id="2">
    <acc:Name>Account Name 2</acc:Name>
    </acc:Account>
    </Results>And see what the difference is...
    Also, the prefix you use in your XPath expression does not have to be the same as the one used in the document. They are linked via the URI and a NamespaceContext. It's quite likely you'll need to implement a NamespaceContext (depending on what XPath API you are using).
    -Rob

  • Xml file not loading

    i am trying to create an e-learning course that will have
    glossaries according to the various lessons that are within the
    overall course. i have attached the code that i am using to quickly
    switch out the glossary xml file (that contains the definitiosn and
    terms). I can currently trace the lessonNumber variable (it is
    reading "1"), but when I attempt to trace the glossaryText
    variable, the output window is blank....can anyone tell me where i
    am going wrong?

    Just a hint - perhaps try putting your onLoad declaration
    BEFORE your load command. This way, your onload is present before
    the load is issued, so in case the XML is loaded really quickly,
    the onLoad handler will get called for sure. Does this make sense?
    In your case, the XML may have already loaded before you tell the
    object WHAT to call after it's loaded.
    When I've used the xml object, it looks more like this:
    myXML = new XML();
    myXML.onLoad = someFunction;
    myXml.load("somexmlfile.xml");
    Also -afterwards, you have to select a node of the XML to
    view. I use the XPath API to do so, by including this
    import mx.xpath.XPathAPI;
    And then using:
    XPathAPI.selectSingleNode within an onLoad function. Take a
    look at the documentation for XPathAPI - I had to make a custom
    function to return the node I wanted.
    Hope this helps you.

  • Reading a XML file in a standalone java application

    Hi,
    What are my options if I have a standalone java application running outside any app. server and I need to read an XML file, probably read some of the attributes in the file...? Please explain clearly as I'm new to this. Appreciate your help.
    Thanks,
    Mahdad

    nope you don't need a DTD
    you have to write your Java code in a way that doesn't rely too much on the structure:
    - avoid getFirstChild().getFirstChild()... because you know that this element is first grandson of that element)
    - prefer using getElementByTagName() or some XPath() API
    but if the XML completely changes, well, yeah, you have to do some programmation: better think well your document structure in the beginning.

  • Urgent help for processing XML stream read from a JAR file

    Hi, everyone,
         Urgently need your help!
         I am reading an XML config file from a jar file. It can print out the result well when I use the following code:
    ===============================================
    InputStream is = getClass().getResourceAsStream("conf/config.xml");
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    String line;
    while ((line = br.readLine()) != null) {
    System.out.println(line); // It works fine here, which means that the inputstream is correct
    // process the XML stream I read from above
    NodeIterator ni = processXPath("//grid/gridinfo", is);
    Below is the processXPath() function I have written:
    public static NodeIterator processXPath(String xpath, InputStream byteStream) throws Exception {
    // Set up a DOM tree to query.
    InputSource in = new InputSource(byteStream);
    DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
    dfactory.setNamespaceAware(true);
    Document doc = dfactory.newDocumentBuilder().parse(in);
    // Use the simple XPath API to select a nodeIterator.
    System.out.println("Querying DOM using " + xpath);
    NodeIterator ni = XPathAPI.selectNodeIterator(doc, xpath);
    return ni;
    It gives me so much errors:
    org.xml.sax.SAXParseException: The root element is required in a well-formed doc
    ument.
    at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213
    at org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XM
    LDocumentScanner.java:570)
    at org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.endO
    fInput(XMLDocumentScanner.java:790)
    at org.apache.xerces.framework.XMLDocumentScanner.endOfInput(XMLDocument
    Scanner.java:418)
    at org.apache.xerces.validators.common.XMLValidator.sendEndOfInputNotifi
    cations(XMLValidator.java:712)
    at org.apache.xerces.readers.DefaultEntityHandler.changeReaders(DefaultE
    ntityHandler.java:1031)
    at org.apache.xerces.readers.XMLEntityReader.changeReaders(XMLEntityRead
    er.java:168)
    at org.apache.xerces.readers.UTF8Reader.changeReaders(UTF8Reader.java:18
    2)
    at org.apache.xerces.readers.UTF8Reader.lookingAtChar(UTF8Reader.java:19
    7)
    at org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.disp
    atch(XMLDocumentScanner.java:686)
    at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
    canner.java:381)
    at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098)
    at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.
    java:195)
    at processXPath(Unknown Source)
    Thank you very much!
    Sincerely Yours
    David

    org.xml.sax.SAXParseException: The root element is required in a well-formed document.This often means that the parser can't find the document. You think it should be able to find the document because your test code could. However if your test code was not in the same package as your real (failing) code, your test is no good because getResourceAsStream("conf/config.xml") is looking for that file name relative to the package of the class that contains that line of code.
    If your test code wasn't in any package, put a slash before the filename and see if that works.

  • Loading XML Variables to Flash

    I have my XML data loading into my SWF OK.
    However, is there any way to call that tag name instead of
    the child node number?
    So instead of something like this:
    myDate_txt.text = my_xml.firstChild.childNodes[2];
    Can do something like this?
    myDate_txt.text = my_xml.firstChild.myDate;
    Is that possible? I know that does not work the way it is
    written, but is there code that you can do something like that?
    And how do you call the next child (cousin) if you have an
    XML document like this:
    <people>
    <friend>
    <name>Bob</name>
    <age>39</age>
    </friend>
    <cousin>
    <name>Sally</name>
    <age>29</age>
    </cousin>
    </people>

    Hi
    Read the Flash Help article related to the XPath API Class,
    and your XML Parsing will be much easier.
    Or go
    here
    Hope it helps

  • Fastest method to load external data?

    Hi,
    Currently we load external xml file and parse it for our
    internal use.
    However, parsing take time, is it possible to reduce this
    step?
    Such as serialize / de-serialize?
    thanks.

    Are you using Xpath API to parse your xml? This will help
    some doing just queries but some parsing will still need to be
    done.
    Another solution is to not load xml but use Flash remoting.
    Flash remoting is a binary format and much faster. WIth Flash
    remoting you can pass all your items in the native formats defined
    in PHP, ASP.Net, or ColdFusion.
    Sean

  • Utility for appending nodes?

    Does anyone know of a utility that allows a user to append a node to a DOM object by providing the appropriate XPath for it?

    er... use Xalan's XPath API to locate the target node (father or sibling of your new node), then append your node using either appendChild() or insertBefore() on the target node...

  • Working with org.w3c.dom.Element

    I have next XML code:
      <union name="FirstUnion">
                 <switch disctype="QuestionType">
                      <case discvalue="List" type="ChoiceSeq" name="choices"/>
                      <default type="ChoiceSeq" name="choices"/>
                 </switch>
       </union>I have org.w3c.dom.Element link which represents switch element .
    So how can I get case or default element by name if i dont want to pass collection by my own code?

    Parse using XPath: "/union/switch/case"
    The 1.5 (maybe 1.4?) JDK has a set of XPath APIs that will work on a parsed DOM.

Maybe you are looking for