用于解析XML的JavaScript

时间:2015-11-30 11:47:58

标签: javascript xml xpath

我想使用java脚本读取xml文件,xml包含以下代码。

<?xml version="1.0" encoding="UTF-8"?><?mso-infoPathSolution solutionVersion="1.0.0.386" productVersion="12.0.0" PIVersion="1.0.0.0" href="http://sites/Software_Release/DatastageReleaseRequests/Datastage%20Release%20Requests/Forms/template.xsn" name="urn:schemas-microsoft-com:office:infopath:Datastage-Release-Requests:-myXSD-2011-07-18T09-53-25" ?><?mso-application progid="InfoPath.Document"?><?mso-infoPath-file-attachment-present?><my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:s0="http://microsoft.com/webservices/SharePointPortalServer/UserProfileService" xmlns:s1="http://microsoft.com/wsdl/types/" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2011-07-18T09:53:25" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-gb">
    <my:Project_Details>
        <my:Project_Title>Warranty </my:Project_Title>
        <my:Project_Code>xxxxx</my:Project_Code>

    </my:Project_Details>
    <my:Change_Details>
        <my:StartDateTime>2014-09-02T16:00:00</my:StartDateTime>
        <my:EndDateTime>2014-09-03T18:00:00</my:EndDateTime>
        <my:Change_Number>0000000</my:Change_Number>
        <my:TaskNumber></my:TaskNumber>
        <my:DryRunDate xsi:nil="true"></my:DryRunDate>
        <my:FirstLiveRunDate>2014-09-02</my:FirstLiveRunDate>
        <my:WarrantyEndDate>2014-09-03</my:WarrantyEndDate>
        <my:field8></my:field8>
    </my:Change_Details>
    <my:Release_Details>
        <my:HostGroup>
            <my:HostsTable>
                <my:Domain_and_Host>hostname</my:Domain_and_Host>
                <my:Project></my:Project>
            </my:HostsTable>
        </my:HostGroup>
        <my:DeployStartDateTime>2014-09-02T16:30:00</my:DeployStartDateTime>
    </my:Release_Details>
    <my:Header>
        <my:RequestID>sd2914</my:RequestID>
        <my:RequestNumber>2914</my:RequestNumber>
        <my:RequestHeader>sd</my:RequestHeader>
    </my:Header>
    <my:Release_Section>

我想要检索my:Project_Titlemy:Project_Codemy:Change_Numbermy:Domain_and_Host的值。我是脚本新手,请帮助。

谢谢

0 个答案:

没有答案