0

I want to read xml file using java script, the xml contains below code.

<?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>

I want to retrieve values of my:Project_Title, my:Project_Code, my:Change_Number and my:Domain_and_Host. I am very new to scripting, please help.

Thanks

Johan
  • 8,068
  • 1
  • 33
  • 46
Logadu S
  • 3
  • 1
  • 5
  • I want to use javascript to read from the xml file and provide the output as I mentioned in the question, as I said I am beginner to scripting it would be very helpful if I get a script for the above question. – Logadu S Nov 30 '15 at 12:03
  • Are you using a browser? Did you read the question I linked? – Jacob Nov 30 '15 at 12:05
  • I went through the link you have given, but I am reading a file which is stored in windows directory. – Logadu S Nov 30 '15 at 13:18
  • I am looking something like var file = filenanme.xml then the script will read file and provide the output. – Logadu S Nov 30 '15 at 13:21
  • Try that in combination with this question: http://stackoverflow.com/questions/14446447/javascript-read-local-text-file – Jacob Nov 30 '15 at 13:47
  • Have no know experience in writing scripting or coding, basically using HP tools to automate the process which has out of box operations to perform the actions, but we do not have any operation available in the tool to read the xml files. But with current project I need to read xml file to get in inputs from xml and parse as an arguments. I hope you will understand. – Logadu S Nov 30 '15 at 14:00
  • Have you tried my suggestions? You will need to find some way of serving the file to the JavaScript (as discussed in the second link I gave you). From there, you should be able to use the information in the first link to parse the XML. – Jacob Nov 30 '15 at 15:59

0 Answers0