logo
down
shadow

Delete a xml child element from a selected node using FLWOR


Delete a xml child element from a selected node using FLWOR

Content Index :

Delete a xml child element from a selected node using FLWOR
Tag : xml , By : Timbo
Date : December 05 2020, 12:22 PM

Hope this helps In XQuery you can use a recursive function to visit each node and test if that node should be removed. If it should be removed, you do nothing, if it should not be removed you make a copy of it as a new node with the same name element {node-name(.)} { ... and continue visiting its children:
declare namespace  tsip="http://schemas.xx.com/ts/20041221/tsip";
declare function local:transform($root) {
  $root / (typeswitch (.)
   case element(tsip:number) return 
     if (@tsip:form = "wila") then ()
     else .
   case element() return 
      element {node-name(.)} { 
        @*, for $n in node() return local:transform($n)
      }
   default return .
  )
};
local:transform($a)

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Delete selected parent node and child nodes - Collection was modified; enumeration operation may not execute


Tag : chash , By : Paul McKee
Date : March 29 2020, 07:55 AM
wish helps you I have treeview control with one level of parent and child nodes, each node is having a checkbox for selecting nodes after selection if I click remove button I want to delete child or parent what ever is selected, Im using following code and it returns an error , Hope you are using .Net 3.5 or higher.
foreach (TreeNode ChildNode in Item.ChildNodes.ToList())
{
    Item.ChildNodes.Remove(ChildNode);
}
for( int i = Item.ChildNodes.Count - 1; i >= 0; i-- )
{
    Item.ChildNodes.Remove(ChildNode);
}
while (Item.ChildNodes.Count > 0)
{
    Item.ChildNodes.Remove(ChildNode);
}

Delete XML Child Node Element in SQL Server 2008


Tag : sql-server , By : KS9
Date : March 29 2020, 07:55 AM
will help you 1) Try following query to insert data from every ItemServiceRet element into one row (in this case, because there are two ItemServiceRet elements two rows will be inserted):
DECLARE @XmlData XML = N'
<ItemServiceRet> 
    <ListID>80000012-1302270176</ListID> 
    <EditSequence>1302270195</EditSequence>
    <Name>2nd Floor Shop</Name>
    <FullName>2nd Floor Shop</FullName> 
    <IsActive>true</IsActive>
    <SalesOrPurchase>
        <Price>0.00</Price>
...
</ItemServiceRet>'

SELECT  ListID          = y.XmlCol.value('(ListID)[1]', 'VARCHAR(19)'),
        EditSequence    = y.XmlCol.value('(EditSequence)[1]', 'INT'),
        -- ...
        Price           = y.XmlCol.value('(SalesOrPurchase/Price)[1]', 'NUMERIC(9,2)'),
        PricePercent    = y.XmlCol.value('(SalesOrPurchase/PricePercent)[1]', 'NUMERIC(9,2)'),
        ListID2         = y.XmlCol.value('(SalesOrPurchase/AccountRef/ListID)[1]', 'VARCHAR(19)')
INTO    #Items
FROM    (VALUES (@XmlData)) x(XmlCol)/*or @XmlData.nodes*/
CROSS APPLY x.XmlCol.nodes(N'ItemServiceRet') y(XmlCol)

/*
Results:
(2 row(s) affected)
*/
SELECT  x.XmlCol.query('
    for $i in (ItemServiceRet)
        return
            <ItemServiceRet>
                <ListID>{$i/ListID/text()}</ListID> 
                <IsActive>{$i/IsActive/text()}</IsActive>
                <Price>{$i/SalesOrPurchase/Price/text()}</Price>
                <PricePercent>{$i/SalesOrPurchase/PricePercent/text()}</PricePercent>
                <AccountRef>
                    <ListID>{$i/SalesOrPurchase/AccountRef/ListID/text()}</ListID>  
                    <FullName>{$i/SalesOrPurchase/AccountRef/FullName/text()}</FullName> 
                </AccountRef>
            </ItemServiceRet>
') AS NewXmlCol
FROM    (SELECT (@XmlData)) x(XmlCol)

I need an XSL transform to insert a child element of the selected node using data from an ancestor


Tag : xml , By : user185144
Date : March 29 2020, 07:55 AM
it helps some times The following XSLT does the job. But because you did not provide a rule for generating the other attributes of the ClientLN node, I (so far) just copied them from your desired output. It should be easy for you to fill them with the desired values.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" />

  <xsl:template match="node()|@*">                       <!-- identity transform -->
    <xsl:copy>
      <xsl:apply-templates select="node()|@*" />
    </xsl:copy>
  </xsl:template>

  <xsl:template match="ReportControl[@rptID = 'PAC']">   <!-- replace special nodes -->
    <xsl:copy>
      <xsl:apply-templates select="node()[not(self::RptEnabled)]|@*" />
      <RptEnabled>
        <xsl:copy-of select="RptEnabled/@*" />
        <ClientLN apRef="S2" ldInst="LD0" lnClass="ITCI" lnInst="1">
          <xsl:attribute name="iedName">
            <xsl:choose>
              <xsl:when test="contains(ancestor::IED/@name,'_220')">APACC_1</xsl:when>
              <xsl:otherwise>APACC_2</xsl:otherwise>
            </xsl:choose>
          </xsl:attribute>
        </ClientLN>
      </RptEnabled>
    </xsl:copy>    
  </xsl:template>     
</xsl:stylesheet>

I'm trying to delete a child element, but I keep getting the error node not found


Tag : javascript , By : pad
Date : March 29 2020, 07:55 AM
I wish this help you check this https://jsfiddle.net/dp722j27/
function deleteItem() {
    var parent = this.parentNode.parentNode.parentNode;
    var item = this.parentNode.parentNode;
    parent.removeChild(item);
}

TSQL Delete XML node if its child element contains a given value


Tag : xml , By : mobi phil
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Metatool for automatic xml code generation
  • Looking for a library of XSLT to create SVG charts
  • How to decide when to use XSD or DTD?
  • BlackBerry - Extract data from 3rd nesting level of xml
  • XSD schema for recursive XML
  • nokogiri xml unescape
  • How to visualize an XML schema?
  • NSString to NSData Failing in Encoding
  • XmlTextWriter.WriteFullEndElement tags on the same line
  • The case of "id" attribute when signing an element in a XML file
  • Increment a counter in VXML
  • how to build xml schema
  • How define several elements with same name, but different type in xsd:choice element?
  • How can you tell if an XMLlist object in AS3 contains a node?
  • Can XML schema be written to allow xs:attribute of either xs:date or xs:dateTime?
  • how to insert a SAML Assertion to SOAPHeader
  • How to migrate from XslTransform to XslCompiledTransform
  • Is there any better IDOMImplementation other than MSXML?
  • Indesign and XML - how to auto flow into multiple pages with differing styles?
  • XSLT - Add a XML node as header
  • Would like to validate a reference to a container in an XML
  • Dataweave - Trying to write END_DOCUMENT when document has no root
  • How can i export Orbeon form data into xml
  • Using XMLQUERY to retrieve specific XML data
  • Is there a semantical difference between <tag /> and <tag></tag> in XML?
  • Importing xml with nested nodes into Access (and needing to transform the xml into a 'flat' structure with xsl)
  • Why is my modified XML not saving the modified values?
  • How to ensure certain immediate siblings always appear in a specific order?
  • How do you handle complex namespaces in XQuery/BaseX?
  • Removing invalid characters from XML in Python3 with etree
  • Grouping/Paginating items from two different parents
  • contracted/expanded tabular display for all principal xml lines
  • How to establish a custom xml serialization with content negotiation in spring boot 2
  • Overcome 2GB limit on XML output in SQL Server
  • How to add a node to an existing XML document using powershell
  • Why is the attribute also append to the child node?
  • Escaping a Dash in XML Element Name With Powershell
  • What is the use of XML?
  • Create dynamic list/array of string - int pairs based on XML input
  • How to flatten a very complex XML into a new XML containing all nodes at root level
  • Looping and summing values from a different tag values in XSLT
  • XML to csv do the correct xslt
  • XML 'name' attribute, and XML variable type with SelectNodes
  • Remove elements from XML based on complex condition
  • Doctrine Invalid Mapping File Exception when trying to generate entities
  • Is it possible to use icons next to radio buttons in odoo 12
  • View responsible for top navbar in Odoo12
  • Best way to query different xml elements as one column
  • unexpected token while reading xml to string in JSR223 sampler
  • Concatenate XML in SQL stored Procedure
  • XSL - Only getting data from one node in my XML
  • XML schema - No matching global declaration available for the validation root
  • How to duplicate an entire XML Node and insert it in the XML data using TSQL
  • Groovy to get node values from XML in SoapUI response
  • XmlEntries to single CosmosDB entries with Azure Function
  • Create child in XML within node by attribute name
  • How to search and edit an xml tag that matches a condtion using xmlstarlet
  • Google App Script XmlService addNamespace method is adding blank XML namespaces to child elements
  • Convert CSV to XML using Mule 4
  • Why is xsl:when and xsl:value-of not working here?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com