Remove node from XML with E4X
How do i do it? I've tried "delete node;" or even node =
null;
Ok, i found a solution to it...
The problem was first of all mostly that i was trying to do
it dynamically, without really telling the name of the child that i
would like to remove.
So, if it was only this that needed to be done:
delete xml.hello;
and the xml looks like
<xml>
<hello>something</hello>
</xml>
it would work. But now i tried to remove a node without
knowing the name of it.
but it works when i did like this:
var node : XML = XML( checkbox.data.node );
var nodeParent : XML = node.parent();
delete nodeParent[node.name()][node.childIndex()];
And it works!
I don't know if it's the best way, but it works and i'm
happy...
Similar Messages
-
How to delete a perticular node from xml file using java code
Hii All,
Now i am trying to delete a perticular node from xml file.Like...
XML file:
<Licence>
<SERVER>
<was id="1">1</was>
<was id="2">2</was>
</SERVER>
</LICENCE>
I am working in messaging service using JABBER framework with whiteboard facility.
Here Some commands i have created to add,modify,delete nodes from xml file.They Are
1.If u want to add a new node then.
create Licence.SERVER <ss id="3">ddd</ss> lic.xml
(here u want to add a new node called "ss" under Licence.SERVER.
And lic.xml is tyhe xml file name where it was saved.
2.If u want to delete a node(Suppose <was id="1">),then the command should be
delete Licence.SERVER.was:id='"1" lic.xml
A problem arises that here it find two was attributes.And it delete the last was attribute,not the requested node.
PLEASE HELP ME IN SOLVING THIS CODE..
------------------------------------Looks like you clicked on "Post" before you pasted in the code you were talking about.
-
How to remove Unicode from XML file
I get following error when unmarshal xml:
[java] org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x15) was found in the element content of the document.
Anyone know how to remove Unicode from xml file? Can I remove the unicode by rebuild the file?
ThanksThese sort of error usually occur when you're using a different character encoding to read the file than the one you wrote it with. Perhaps if you were to post the problem section of the file and/or the code that created it in the first place.
-
Hi,
I have an xml which has some target namespace.
I need to remove the namespace and the qualifiers and put it on a machine using a file adapter.
Any help in this regard is highly appreciated.
With Regards,
HarshPlease go throught the below link
Removing namespace from xml created -
Dynamiclly remove node from JTree
hi all,
I want to remove nodes from a tree dynamically. I used "treeModel.removeNodeFromParent(node);". The node was removed from that treeModel, but the tree never updated. I tried to use tree.repaint() method. It doesn't work. Any suggestion?
thanks a lot in advance.try with TreeModel.reload(); This will surely work
-
Remove element from xml using dom.
i want to remove an element from an xml file using dom.
i remove the element but the whole content of the file is also deleted.
how can i rewrite the file.vij_ay wrote:
subject :Remove element from xml,but if empty element in input file then output should be <tag></tag>, not like <tag.xml/>I assume you mean <tag/> but why do you want this? Any application that will not accept this valid XML construct is flawed and a bug report should be raised against it. -
How to remove empty lines from xml files after removing nodes from document
<pre>
Hi
<b>i have xml document, which is shown below
after removing some nodes from the document ,i am getting empty lines in place of removed nodes,how to resolve this and get the proper xml document without any errors</b>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE Message SYSTEM "TRD01.dtd">
<Message>
<Header>
<CounterPartyType>CLIENT</CounterPartyType>
<CreationTime>20134455</CreationTime>
<ErrorCode>363 </ErrorCode>
<ErrorEnterPriseId>N</ErrorEnterPriseId>
<ErrorStatus>1</ErrorStatus>
<ErrorSystemId>STL</ErrorSystemId>
<ErrorTimes>31</ErrorTimes>
<MessageType>T</MessageType>
<RecipientEnterpriseId>N</RecipientEnterpriseId>
<RecipentSystemId>EXM</RecipentSystemId>
<Remarks>REMARSK</Remarks>
<SenderEnterpriseId>N</SenderEnterpriseId>
<SenderSystemId>TR</SenderSystemId>
</Header>
</Message>
<ErrorCode>363 </ErrorCode>
<ErrorEnterPriseId>NIHK</ErrorEnterPriseId>
<ErrorStatus>1</ErrorStatus>
<ErrorSystemId>STL</ErrorSystemId>
<ErrorTimes>31</ErrorTimes>
XPathExpression expression5 = xpath.compile(xmlpath5);
Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
Node node5 = (Node) result5;
node5.getParentNode().removeChild(node5);
XPathExpression expression6 = xpath.compile(xmlpath6);
Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
Node node6=(Node) result6;
node6.getParentNode().removeChild(node6);
XPathExpression expression7 = xpath.compile(xmlpath7);
Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
Node node7=(Node) result7;
node7.getParentNode().removeChild(node7);
doc.normalize();
doc.normalizeDocument();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
t.setOutputProperty(OutputKeys.METHOD,"xml");
t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
the xml output i am getting is
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Message>
<Header>
<CounterPartyType>CLIENT</CounterPartyType>
<CreationTime>20134455</CreationTime>
<MessageType>TRD01</MessageType>
<RecipientEnterpriseId>N</RecipientEnterpriseId>
<RecipentSystemId>STL</RecipentSystemId>
<Remarks>REMARSK</Remarks>
<SenderEnterpriseId>N</SenderEnterpriseId>
<SenderSystemId>T</SenderSystemId>
</Header>
</Message>
<b>could you please let me know how to avoid empty lines in the xml doucment output</b>
this is the method i am using to get the result
public void ValidateRecord(String xml){
try{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder db = factory.newDocumentBuilder();
//parse file into DOM
/*DOMParser parser = new DOMParser();
parser.setErrorStream(System.err);
parser.setValidationMode(DTD_validation);
parser.showWarnings(true);*/
System.out.println ("HI THIS xml is validation "+xml);
Resolver res = new Resolver();
db.setEntityResolver(res);
Document doc = db.parse(new InputSource(new StringReader(xml)));
XPathFactory xpf = XPathFactory.newInstance();
XPath xpath = xpf.newXPath();
// XPathExpression expression = xpath.compile("//A/B[C/E/text()=13]");
String xmlpath="/Message/Header/CounterPartyType/text()";
String xmlpath1="/Message/Header/RecipentSystemId/text()";
String xmlpath2="/Message/Header/ErrorSystemId/text()";
XPathExpression expression = xpath.compile(xmlpath);
XPathExpression expression1 = xpath.compile(xmlpath2);
Object result = expression.evaluate(doc, XPathConstants.NODE);
Object result1 = expression1.evaluate(doc, XPathConstants.NODE);
Node node = (Node) result;
Node node1 = (Node) result1;
System.out.println("the values of the string is " +node.getNodeValue());
System.out.println("the values of the string is " +node1.getNodeValue());
// for (int i = 0; i < nodes.getLength(); i++) {
//System.out.println(nodes.item(i).getNodeValue());
// CAHNGING THE RECEIPENT NODE
XPathExpression expression2 = xpath.compile(xmlpath1);
Object result2 = expression2.evaluate(doc, XPathConstants.NODE);
Node node2 = (Node) result2;
System.out.println(node2);
node2.setNodeValue(node1.getNodeValue());
System.out.println(node2);
//removing the nodes from document
String xmlpath3="/Message/Header/ErrorCode";
String xmlpath4="/Message/Header/ErrorEnterPriseId";
String xmlpath5="/Message/Header/ErrorStatus";
String xmlpath6="/Message/Header/ErrorSystemId";
String xmlpath7="/Message/Header/ErrorTimes";
XPathExpression expression3 = xpath.compile(xmlpath3);
Object result3 = expression3.evaluate(doc, XPathConstants.NODE);
Node node3 = (Node) result3;
node3.getParentNode().removeChild(node3);
XPathExpression expression4 = xpath.compile(xmlpath4);
Object result4 = expression4.evaluate(doc, XPathConstants.NODE);
Node node4 = (Node) result4;
System.out.println("node value");
System.out.println(node4.getParentNode().getNodeName());
node4.getParentNode().removeChild(node4);
XPathExpression expression5 = xpath.compile(xmlpath5);
Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
Node node5 = (Node) result5;
node5.getParentNode().removeChild(node5);
XPathExpression expression6 = xpath.compile(xmlpath6);
Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
Node node6=(Node) result6;
node6.getParentNode().removeChild(node6);
XPathExpression expression7 = xpath.compile(xmlpath7);
Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
Node node7=(Node) result7;
node7.getParentNode().removeChild(node7);
// Node b13Node = (Node) expression.evaluate(doc, XPathConstants.NODE);
//b13Node.getParentNode().removeChild(b13Node);
doc.normalize();
doc.normalizeDocument();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer t = tf.newTransformer();
t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
t.setOutputProperty(OutputKeys.METHOD,"xml");
t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
t.transform(new DOMSource(doc), new StreamResult(System.out));
catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
</pre>
Edited by: user12185243 on Apr 6, 2013 6:38 AM
Edited by: user12185243 on Apr 6, 2013 6:41 AM
Edited by: user12185243 on Apr 6, 2013 6:43 AM
Edited by: user12185243 on Apr 6, 2013 6:45 AM
Edited by: user12185243 on Apr 6, 2013 9:00 AMeither this way we can do this
1)
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
<b> factory.setIgnoringElementContentWhitespace(true); </b>
DocumentBuilder db = factory.newDocumentBuilder();
or
2)
java.io.StringWriter sw = new java.io.StringWriter();
StreamResult sr = new StreamResult(sw);
t.transform(new DOMSource(doc), sr);
String xml1 = sw.toString().trim();
<b> xml1=xml1.replaceAll("\\s",""); </b>
System.out.println(xml1.trim()); -
Oracle SQL - Extracting clob value from XML with repeating nodes
Hi All,
I am attempting to run SQL on a table (called test_xml with a column xml_data [data type xmltype]). The column contains xml with repeating nodes (description). The following statement runs successfully when the node contains data of a non clob size:
SELECT
extractvalue (Value (wl), '*/description')
FROM test_xml
, TABLE (xmlsequence (extract (xml_data, '*/record'))) wl
but fails when description node contains a lot of data:
ORA-01706: user function result value was too large
I amended my query:
SELECT
extractvalue(Value (wl), '*/description').getClobVal()
FROM test_xml
, TABLE (xmlsequence (extract (xml_data, '*/record'))) wl
but this fails with:
ORA-22806: not an object or REF
Thanks in AdvanceHi Greg,
11.2.0.2.0 (Although I will need to do this on my work instance also which is 10.2.0.4)That's gonna be a problem...
Direct CLOB projection is supported starting with 11.2.0.2, using XMLTable or XMLCast/XQuery functions (extractvalue, extract, xmlsequence are deprecated now) :
SELECT x.*
FROM test_xml t
, XMLTable(
'/*/record'
passing t.xml_data
columns
description clob path 'description'
) x
;On prior versions, implicit conversions will occur to VARCHAR2 datatype, hence the limitation observed.
AFAIK you have two options on 10.2.0.4 :
1) Using Object-Relational storage, with the xdb:SQLType="CLOB" annotation.
2) Using the following trick :
SELECT dbms_xmlgen.convert(x.description.getClobVal(), 1) as description
FROM test_xml t
, XMLTable(
'/*/record'
passing t.xml_data
columns
description xmltype path 'description/text()'
) x
; -
Remove Namespace from XML File except Attribute
Hi XI Experts ,
1.I have referred to the code of xslt Generic XSLT Code to Remove ALL Namespaces from XML:
http://forums.sdn.sap.com/thread.jspa?threadID=1920630
But this removes the Attribute : id from the records .
My expected output is supposed to be :
<?xml version="1.0" encoding="GBK"?>
<body>
<head>
<nsrsbh>112001069711</nsrsbh>
<nsrmc>诺维信(中国)生物技术有限公司出口发票</nsrmc>
<dcrq>20120209</dcrq>
<sssq_q>20111201</sssq_q>
<sssq_z>20120207</sssq_z>
<records>4</records>
</head>
<data>
<record id="1">
<fpdm></fpdm>
</record>
</data>
</body
But after using this XSLT code it removes :id from <record_1 id=> and generated the below code :
The xml file now doesn't contain teh attribute :id
<?xml version="1.0" encoding="GBK"?>
<body>
<head>
<nsrsbh>112001069711</nsrsbh>
<nsrmc>诺维信(中国)生物技术有限公司出口发票</nsrmc>
<dcrq>20120209</dcrq>
<sssq_q>20111201</sssq_q>
<sssq_z>20120207</sssq_z>
<records>4</records>
</head>
<data>
<record>
1
<fpdm></fpdm>
</record>
</data>
</body>
Could you please provide your input
Plaese note : Here XI versin iS x1 3.0 SP7 . I have tried suing the Analyzer bean for the Encoing of Chinese : GBK Intsead of UTF-8 in the Namespace . But AF_Modules/XMLAnonymizerBean is not comptacible with XI 3.0 SP7
Hence i have used the following code to remove namespcae and add Encoding :GBK instead of UTF-8:
<?xml version="1.0" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="GBK"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>You could use exclude-result-prefixes.
For example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wt="http://www.example.com" exclude-result-prefixes="wt">
</xsl:stylesheet> -
Deleting Nodes from XML Tree (JTree)
I have created a XML Tree(extended from JTree) using XNodes ( extended from DefaultMutableTreeNode)
After some insertions, i need to delete certain nodes from the XML Tree.. but after deletion, XNode will be null.
subroutine is as follows...
appreciates any advice
Thanx
private XNode RemoveExtraNode( XNode xNode ){
int child;
String nodeType;
XNode childNode=null;
if ( (child=xNode.getChildCount() ) > 0){
for(int i=0;i<child;i++){
childNode=(XNode)xNode.getChildAt(i);
nodeType = childNode.getType();
if(nodeType.equals("DTD") )
childNode.removeFromParent();
}//end for (int i=1;i<child;i++)
}//endif((child=xNode.getChildCount())!=0)
return xNode;
}//RemoveExtraNodeHi IKEDA
Thanx for the reply.
I have tried xNode.remove(childNode) b4 and it still return a null JTree.
Anyway fyi i discover i can delete last child of xNode and return the correct java tree. therefore to delete a node of my choice i simply insert its next sibling nodes in its place and delete that particular node when it becomes the last child. -
Copy node from XML tree problem
I am trying to copy an XML node 9whic hmay have child nodes) from one tree to another with the code
nodes = dataDoc.getElementsByTagName("text");
currentElement = (Element) nodes.item(0);
textNode.appendChild(nodes.item(0).cloneNode(true));
gives the error
org.apache.crimson.tree.DomEx: WRONG_DOCUMENT_ERR: That node doesn't belong in this document.
at org.apache.crimson.tree.ParentNode.checkDocument(ParentNode.java:250)
at org.apache.crimson.tree.ParentNode.appendChild(ParentNode.java:333)
What am I doing wrong?
Regards,
MArkWhat am I doing wrong?Failing to use the Document.importNode() method.
-
Error removing object from cache with write behind
We have a cache with a DB for a backing store. The cache has a write-behind delay of about 10 seconds.
We see an error when we:
- Write new object to the cache
- Remove object from cache before it gets written to cachestore (because we're still within the 10 secs and the object has not made it to the db yet).
At first i was thinking "coherence should know if the object is in the db or not, and do the right thing", but i guess that's not the case?Hi Ron,
The configuration for <local-scheme> allows you to add a cache store but you cannot use write-behind, only write-through.
Presumably you do not want the data to be shared by the different WLS nodes, i.e. if one node puts data in the cache and that is eventually written to a RAC node, that data cannot be seen in the cache by other WLS nodes. Or do you want all the WLS nodes to share the data but just write it to different RAC nodes?
If you use a local-scheme then the data will only be local to that WLS node and not shared.
I can think of a possible way to do what you want but it depends on the answer to the above question.
JK -
Hi,
to delete my node2 from the last quorum device, i tried > scconf -r -q globaldev=d3 -h node=node2
but it is not working, i man the scconf cmd but not helpful and not understand, anyone can help me ? what should be the parameter to be appended behind after the globaldev=d3 ?
tks.Hi,
the man page for scconf clearly states that the only argument to "scconf -q -r" is "name=devicename". There seems to be no way to remove a node from a quorum device. The clquorum(SC3.2) man page is a little clearer here. It says: " You can remove only a quorum device. You cannot use this subcommand to remove cluster nodes." And for the clq add command it says: "The quorum device is added with connection paths in the cluster configuration to every node to which the device is connected. Later, if the connection between the quorum device and the cluster nodes changes, you must update the paths. Update the paths by removing the quorum device and then adding it back to the configuration. This situation could arise if you add more nodes that are connected to the quorum device or if you disconnect the quorum device from one or more nodes."
I am not sure whether this helps you. What were you really trying to achieve?
Regards
Hartmut -
Hi,
I am quite new to JavaFX.
What I need is to remove a node from the scene.
I tried with "delete node" and "node = null" but the graphics of the node don't dissapear from the scene.
Any help on this?nothing :(
my code is:
delete RauGroup.content[3] from RauScene.content;where RauScene is:
var RauScene:Scene = Scene{
content:[
HBox{
content:[
SettingsGroup,
RauSettingsToggleButton,
RauGroup
}I also tried removing the whole RauGroup from the RauScene but with no different outcome :/ -
Remove Applications from "Open With..." List
Ever since I installed Adobe Creative Suite, there have been countless applications available in the Open With... list for image file types (JPEGs, PNGs, etc.).
How do I remove applications from that list for a given file type?
Thanks!There are a whole bunch of mostly useless little droplets that are installed by Photoshop and ImageReady. You can either toss them all, toss all but the one or two you might use, or just zip them and then if you ever want one unzip, take what you want and rezip the others (I kept Make Sepia Tone.exe and zipped all the others, and put a text file with a list of them all in the parent folder). Here's the location:
"/Applications/Adobe Photoshop CS/Samples/Droplets"
There is one folder full of ImageReady ones, and another folder of the Photoshop ones. If you trash them you can also get them back from the install disk. After you zip or trash them restart the computer and your Open with list will be back to normal.
Francine
Francine
Schwieder
Maybe you are looking for
-
Greetings, Does anyone have experience migrating mail boxes from OSX 10.4 to OSX 10.7? I have an old 1.5 Ghz PowerPC G4 laptop with a lot of email (about 8 years worth). I just purchased a new Mac Mini with OSX 10.7 Lion and I'd like to migrate 2 gro
-
Want to add one new column in Report form
Hi all, I have searched in forum but not able to find the answer. I want to add one new column in form 12KST1C. I have added one column PR commitment in left and saved the form, it is showing in form but when i am running the report again then pr com
-
How can I speed up the time it takes to deliver mail to lists I build in Workgroup Manager?
My research group uses Workplace Manger to create mailing lists that we use to email each other. The lists work correctly, but take a long time - when an email is sent from any computer to the mailing address we create (like [email protected]), it ta
-
How do I creat a new account on my oldMacBook Pro si that I can give it to my daughter ?
Hello I haven't tried this before so lets try . I've given my old MacBook Pro to daughter and need to know hoe to set up a new account for her ? Can anyone give me step by step instructions to do this ?
-
I am using jetty as embedded server as part of other application. The problem I have is I can't seem to start the server. The file (i'm pretty new to java, so this is probably a sloppy programming style): // import org.mortbay.jetty.Server; and all f