Professional Web Applications Themes

Problem Using XmlSearch on XML File With Namespaces and Schema - Coldfusion - Advanced Techniques

Can anyone help me? I am trying to perform an XmlSearch on the XML file below (from a SQL Server database). All of the information I could find using Google and this Google group does not work for this file. I have tried the following xPathString = "//:Table"; xPathString = "//*[local-name() = 'cmsSvc04Results' and namespace-uri = 'http://tempuri.org/cmsWebServices/cmsDatServices']"; xPathString = "/cmsSvc04Results/diffgr/cmsSvc04Results//Table[1]"; xPathString = "/:Table"; Any help would be greatly appreciated. XML File: <?xml version="1.0" encoding="utf-8"?> <mtdataResults xmlns="http://tempuri.org/cmsWebServices/cmsDatServices"> <xs:schema id="mtdataResults" targetNamespace="http://tempuri.org/mtdataDataFormat.xsd" xmlns:mstns="http://tempuri.org/mtdataDataFormat.xsd" xmlns="http://tempuri.org/mtdataDataFormat.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified"> <xs:element name="mtdataResults" msdata:IsDataSet="true"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="EmployeeData"> <xs:complexType> <xs:sequence> <xs:element name="TransactionToken" msdata:ReadOnly="true" type="xs:string" minOccurs="0" ...

  1. #1

    Default Problem Using XmlSearch on XML File With Namespaces and Schema

    Can anyone help me? I am trying to perform an XmlSearch on the XML file
    below (from a SQL Server database). All of the information I could find
    using Google and this Google group does not work for this file. I have
    tried the following

    xPathString = "//:Table";
    xPathString = "//*[local-name() = 'cmsSvc04Results' and namespace-uri =
    'http://tempuri.org/cmsWebServices/cmsDatServices']";
    xPathString = "/cmsSvc04Results/diffgr/cmsSvc04Results//Table[1]";
    xPathString = "/:Table";

    Any help would be greatly appreciated.

    XML File:

    <?xml version="1.0" encoding="utf-8"?>
    <mtdataResults
    xmlns="http://tempuri.org/cmsWebServices/cmsDatServices">
    <xs:schema id="mtdataResults"
    targetNamespace="http://tempuri.org/mtdataDataFormat.xsd"
    xmlns:mstns="http://tempuri.org/mtdataDataFormat.xsd"
    xmlns="http://tempuri.org/mtdataDataFormat.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
    attributeFormDefault="qualified" elementFormDefault="qualified">
    <xs:element name="mtdataResults" msdata:IsDataSet="true">
    <xs:complexType>
    <xs:choice maxOccurs="unbounded">
    <xs:element name="EmployeeData">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="TransactionToken"
    msdata:ReadOnly="true" type="xs:string" minOccurs="0" />
    <xs:element name="ReturnCode" msdata:ReadOnly="true"
    type="xs:int" minOccurs="0" />
    <xs:element name="MaxRowNo" msdata:ReadOnly="true"
    type="xs:int" minOccurs="0" />
    <xs:element name="CurrentRowNo" msdata:ReadOnly="true"
    type="xs:int" minOccurs="0" />
    <xs:element name="EmployeeName" msdata:ReadOnly="true"
    type="xs:string" minOccurs="0" />
    <xs:element name="Official_Title" type="xs:string"
    minOccurs="0" />
    <xs:element name="CompID" type="xs:int" />
    <xs:element name="CompDesignator" type="xs:string"
    minOccurs="0" />
    <xs:element name="CompTitle" type="xs:string"
    minOccurs="0" />
    <xs:element name="ValidationMethod"
    msdata:ReadOnly="true" type="xs:string" minOccurs="0" />
    <xs:element name="ValidateDate" msdata:ReadOnly="true"
    type="xs:string" minOccurs="0" />
    <xs:element name="EmpProficiencyLevel"
    msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
    <xs:element name="RqdPosProficiencyLevel"
    msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
    <xs:element name="EmpHasCompFlag"
    msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
    <xs:element name="PosRequiresCompFlag"
    msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
    <xs:element name="PrimaryCompFlag" type="xs:boolean" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="Table">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="TransactionToken" type="xs:string"
    minOccurs="0" />
    <xs:element name="ReturnCode" type="xs:int"
    minOccurs="0" />
    <xs:element name="MaxRowNo" type="xs:int" minOccurs="0"
    />
    <xs:element name="CurrentRowNo" type="xs:int"
    minOccurs="0" />
    <xs:element name="EmployeeName" type="xs:string"
    minOccurs="0" />
    <xs:element name="PositionTitle" type="xs:string"
    minOccurs="0" />
    <xs:element name="CompID" type="xs:int" minOccurs="0"
    />
    <xs:element name="CompDesignator" type="xs:string"
    minOccurs="0" />
    <xs:element name="CompTitle" type="xs:string"
    minOccurs="0" />
    <xs:element name="ValidationMethod" type="xs:string"
    minOccurs="0" />
    <xs:element name="ValidationDate" type="xs:string"
    minOccurs="0" />
    <xs:element name="EmpProficiencyLevel" type="xs:short"
    minOccurs="0" />
    <xs:element name="RqdPosProficiencyLevel"
    type="xs:short" minOccurs="0" />
    <xs:element name="EmpHasCompFlag" type="xs:boolean"
    minOccurs="0" />
    <xs:element name="PosRequiresCompFlag"
    type="xs:boolean" minOccurs="0" />
    <xs:element name="PrimaryCompFlag" type="xs:boolean"
    minOccurs="0" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:choice>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    <diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
    xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
    <mtdataResults xmlns="http://tempuri.org/mtdataDataFormat.xsd">
    <Table diffgr:id="Table1" msdata:rowOrder="0">
    <TransactionToken>THISTOKENWAS009</TransactionToken>
    <ReturnCode>801</ReturnCode>
    <MaxRowNo>19</MaxRowNo>
    <CurrentRowNo>0</CurrentRowNo>
    </Table>
    <Table diffgr:id="Table2" msdata:rowOrder="1">
    <CurrentRowNo>1</CurrentRowNo>
    <EmployeeName>JOHN DOE</EmployeeName>
    <PositionTitle>Good Employee</PositionTitle>
    <CompID>9</CompID>
    <CompDesignator>INTEGENG</CompDesignator>
    <CompTitle>Integration Engineering</CompTitle>
    <ValidationDate>02/16/05</ValidationDate>
    <EmpProficiencyLevel>3</EmpProficiencyLevel>
    <RqdPosProficiencyLevel>0</RqdPosProficiencyLevel>
    <EmpHasCompFlag>true</EmpHasCompFlag>
    <PosRequiresCompFlag>false</PosRequiresCompFlag>
    <PrimaryCompFlag>false</PrimaryCompFlag>
    </Table>
    <Table diffgr:id="Table3" msdata:rowOrder="2">
    <CurrentRowNo>2</CurrentRowNo>
    <EmployeeName>JOHN DOE</EmployeeName>
    <PositionTitle>Good Employee</PositionTitle>
    <CompID>10</CompID>
    <CompDesignator>TESTENG</CompDesignator>
    <CompTitle>Test Engineering</CompTitle>
    <ValidationDate>02/16/05</ValidationDate>
    <EmpProficiencyLevel>3</EmpProficiencyLevel>
    <RqdPosProficiencyLevel>0</RqdPosProficiencyLevel>
    <EmpHasCompFlag>true</EmpHasCompFlag>
    <PosRequiresCompFlag>false</PosRequiresCompFlag>
    <PrimaryCompFlag>false</PrimaryCompFlag>
    </Table>
    <Table diffgr:id="Table4" msdata:rowOrder="3">
    <CurrentRowNo>3</CurrentRowNo>
    <EmployeeName>JOHN DOE</EmployeeName>
    <PositionTitle>Good Employee</PositionTitle>
    <CompID>27</CompID>
    <CompDesignator>SAFENG</CompDesignator>
    <CompTitle>Safety Engineering and Assurance</CompTitle>
    <ValidationDate>02/16/05</ValidationDate>
    <EmpProficiencyLevel>3</EmpProficiencyLevel>
    <RqdPosProficiencyLevel>0</RqdPosProficiencyLevel>
    <EmpHasCompFlag>true</EmpHasCompFlag>
    <PosRequiresCompFlag>true</PosRequiresCompFlag>
    <PrimaryCompFlag>true</PrimaryCompFlag>
    </Table>
    </mtdataResults>
    </diffgr:diffgram>
    </mtdataResults>

    Zeke_the_Geek Guest

  2. #2

    Default Re: Problem Using XmlSearch on XML File With Namespaces and Schema

    BTW: I am trying to get to the information store in the TABLE tags
    children (e.g., CompID)

    Zeke_the_Geek wrote: 

    Zeke_the_Geek Guest

  3. #3

    Default Re: Problem Using XmlSearch on XML File With Namespaces and Schema

    And the answer is...

    xPathString = "/*[local-name()='cmsSvc04Results' and
    namespace-uri()='http://tempuri.org/cmsWebServices/cmsDatServices']/*[local-name()='diffgram'
    and
    namespace-uri()='urn:schemas-microsoft-com:xml-diffgram-v1'][1]/*[local-name()='cmsSvc04Results'
    and
    namespace-uri()='http://tempuri.org/cmsSvc04DataFormat.xsd'][1]/*[local-name()='Table'
    and namespace-uri()='http://tempuri.org/cmsSvc04DataFormat.xsd']";

    Until I get a good handle on forming XPath queries, I downloaded Stylus
    Studio(R) XML Home Edition
    (http://www.stylusstudio.com/stylus_home_edition.html) and used the
    studio's Xpath Generator
    (http://www.stylusstudio.com/xpath_generator.html). "Stylus Studio(R)
    includes an XPath generator that helps you easily create XPath
    expressions. To generate an XPath expression, open an XML doent in
    Tree View. Tree View allows you to quickly expand and collapse the
    nodes of an XML doent. When you've found the XML element or
    attribute for which you want to construct an XPath expression, just
    right-click and choose Copy XPath Query to Clipboard from the shortcut
    menu, as shown in the following illustration. You can then paste the
    XPath expression generated by Stylus Studio(R) into any of Stylus
    Studio(R)'s XML editors."

    If not used in any other way for XML handling, Stylus Studio(R) is well
    worth the money!

    Zeke_the_Geek Guest

Similar Threads

  1. Trouble with schema file!
    By bredal Jensen in forum ASP.NET Web Services
    Replies: 0
    Last Post: August 5th, 01:28 PM
  2. installation problem XML::Schema
    By Antoine Janssen in forum PERL Modules
    Replies: 0
    Last Post: September 22nd, 11:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139