none
Sharepoint word web add-in how to get text of specific node of customxml part using javascript word api RRS feed

  • Question

  • Hi, I am creating word add-in and i want to get value of a specific node of customxml part. I have many nodes but i want to get a specific node text. Currently i am fetching this using loop through all the items. Help me to get specific node text.

    Here is my code and my custom xml

    Office.context.document.customXmlParts.getByNamespaceAsync(nameSpace, function(asyncResult1) {
                if (asyncResult1.value != null && asyncResult1.value.length > 0) {
        asyncResult1.value[0].getNodesAsync('/ns0:properties[1]/documentManagement[1]/documentManagement[1]', function (documentManagementNodeResults) {
                        if (documentManagementNodeResults.value != null && 
                          documentManagementNodeResults.value.length > 0) {
                            documentManagementNodeResults.value[0].getNodesAsync('*', function (documentManagementSubNodeResults) {
                                for (var i = 0; i < documentManagementSubNodeResults.value.length; i++) {
                                    var node = documentManagementSubNodeResults.value[i];
                                    switch (node.baseName) {
                                        case "EmployeeName":
                                            node.getXmlAsync({}, function (result) {
                                                var value = result.value;
                                                if (value != undefined && value != "") {
                                                    var mySubString = value.substring(value.lastIndexOf('">') + 2, value.lastIndexOf("</"));
                                                    //mySubString This is text of EmployeeName node
                                                } 
                                            });
    								break;
    								}
    							}
    						}
    					}
    				}
    			}
     }

    Here is xml

    <?xml version="1.0" encoding="UTF-8"?>
    -<p:properties xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://schemas.microsoft.com/office/2006/metadata/properties">
    -<documentManagement>
    <ContractSupplierName xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Kaas-Pandrup Betonvarefabrik</ContractSupplierName>
    <ContractCalculatedBonus xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Bonus beregnes som</ContractCalculatedBonus>
    <ContractDeliveryType xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">alle leveringer</ContractDeliveryType>
    <ContractContactPerson xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractAnnex3 xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">false</ContractAnnex3>
    <ContractAnnex6 xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">false</ContractAnnex6>
    <ContractAnnex7Text xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Ikke Relevant</ContractAnnex7Text>
    <ContractApprovalDate xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractSupplierZipCodeCity xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">9490</ContractSupplierZipCodeCity>
    <ContractBonusXML xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractCompensation1 xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">false</ContractCompensation1>
    <ContractSupplierAddress xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Bransagervej 27</ContractSupplierAddress>
    <ContractBuyersdelivery xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractSupplierAddress1 xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractSupplierNo xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">806433</ContractSupplierNo>
    <ContractSupplierCVRno xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">62024011</ContractSupplierCVRno>
    <ContractDeliveryTypeXML xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractAnnex7 xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">false</ContractAnnex7>
    <ContractCompensation xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractAnnex6Text xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Ikke Relevant</ContractAnnex6Text>
    <ContractTwentyTwoThree xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">false</ContractTwentyTwoThree>
    <ContractContactSupplier xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">peter Iversen</ContractContactSupplier>
    <ContractNonEligibleProducts xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractDocumentItemId xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">5990</ContractDocumentItemId>
    -<ContractAprrover xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">
    -<UserInfo>
    <DisplayName/>
    <AccountId xsi:nil="true"/>
    <AccountType/>
    </UserInfo>
    </ContractAprrover>
    <ContractNotes xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractTwentyTwoTwo xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">false</ContractTwentyTwoTwo>
    -<ContractCategoryChef xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">
    -<UserInfo>
    <DisplayName/>
    <AccountId xsi:nil="true"/>
    <AccountType/>
    </UserInfo>
    </ContractCategoryChef>
    <ContractCompensation2Point xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractPrivateLabelPoint2 xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractSGDDMail xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">aa@insteq.com</ContractSGDDMail>
    <ContractCompensation1Point xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Ikke relevant</ContractCompensation1Point>
    <ContractSupplierMail xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">sadd</ContractSupplierMail>
    <ContractSgddSecondTel xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">3123</ContractSgddSecondTel>
    <ContractMarketingXML xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    -<ContractReviewer xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">
    -<UserInfo>
    <DisplayName/>
    <AccountId xsi:nil="true"/>
    <AccountType/>
    </UserInfo>
    </ContractReviewer>
    <ContractTwentyTwoOne xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">false</ContractTwentyTwoOne>
    <ContractBrand xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Optimera</ContractBrand>
    <ContractAgreementValidDate xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractContactSGDDName xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Aftab Ahmad</ContractContactSGDDName>
    <ContractExpireDateText xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">ny aftale indgås</ContractExpireDateText>
    <ContractContactPersonElect xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    -<ContractContactSGDD1 xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">
    -<UserInfo>
    <DisplayName/>
    <AccountId xsi:nil="true"/>
    <AccountType/>
    </UserInfo>
    </ContractContactSGDD1>
    <ContractSupplierExtraBonusTexts xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Yder Leverandøren ekstraordinær projektbonus fratrækkes denne ikke det bonusberettigede køb</ContractSupplierExtraBonusTexts>
    <ContractOtherTermsAgree xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractExpireDate xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractSupplierTEL xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">312</ContractSupplierTEL>
    <ContractStartDate xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractReturnablePackaging xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractSupplierCity xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Pandrup</ContractSupplierCity>
    <ContractNewStoreDiscount xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractPrivateLabelInsert xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">false</ContractPrivateLabelInsert>
    <ContractPaymentTerms xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractSupplierExtraBonus xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">true</ContractSupplierExtraBonus>
    -<ContractCategoryDirector xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">
    -<UserInfo>
    <DisplayName/>
    <AccountId xsi:nil="true"/>
    <AccountType/>
    </UserInfo>
    </ContractCategoryDirector>
    <ContractOtherTermsAgreeTwo xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractIsNewStoreDiscount xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">false</ContractIsNewStoreDiscount>
    <ContractSGDDTEL xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">312</ContractSGDDTEL>
    <ContractAnnex3Text xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Ikke Relevant</ContractAnnex3Text>
    <ContractAgreedDeliveryTime xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractClosingDate xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">2018-11-22T10:57:33+00:00</ContractClosingDate>
    -<ContractAuthor xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">
    -<UserInfo>
    <DisplayName/>
    <AccountId xsi:nil="true"/>
    <AccountType/>
    </UserInfo>
    </ContractAuthor>
    <ContractStatus1 xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">Kladde</ContractStatus1>
    <ContractMailVBXML xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractOtherTermsAgreeThree xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    <ContractIsDanishContract xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">false</ContractIsDanishContract>
    <ContractContactIsDanish xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b">true</ContractContactIsDanish>
    <ContractStartDateText xmlns="340fd96a-2929-4a6b-8ce0-e46b74103a8b" xsi:nil="true"/>
    </documentManagement>
    </p:properties>

     

    Thursday, January 24, 2019 1:23 PM