How to check if a node exists in the XML file?
I was asked to program a method to import data from xml files in our Coldfusion 8 Web site, I am new to the use of XML.
My method worked however I encountered the following error:
Element NETWORKORDER. SECONDARYADDRESS. CONTACTNAME is undefined in MYDOC.
Investigation on the node in the XML file was not present.
Is there a method I can use to resolve this error by checking if a node exists in the xml file, which works with my current code below?
<!--> reading XML file
< cffile action = "read" file = "D:\website\XML\#FileName#" variable = "myxml" >
< cfset mydoc = XmlParse (myxml) >
<!--> to extract data from the XML of NDS file
< cfset aPrimaryContactName =(#mydoc.NetworkOrder.PrimaryAddress.ContactName#) >
< cfset aPrimaryContactNumber =(#mydoc.NetworkOrder.PrimaryAddress.ContactNumber#) >
< cfset aPrimaryContactNumber = tostring(#mydoc.NetworkOrder.PrimaryAddress.ContactNumber#) >
< cfset aPrimaryContactAddressLine1 =(#mydoc.NetworkOrder.PrimaryAddress.line1#) >
< cfset aPrimaryContactAddressLine2 =(#mydoc.NetworkOrder.PrimaryAddress.line2#) >
< cfset aPrimaryContactAddressLine3 =(#mydoc.NetworkOrder.PrimaryAddress.line3#) >
< cfset aPrimaryContactAddressLine4 =(#mydoc.NetworkOrder.PrimaryAddress.line4#) >
< cfset aPrimaryContactAddressLine5 =(#mydoc.NetworkOrder.PrimaryAddress.line5#) >
< cfset aPrimaryContactCity =(#mydoc.NetworkOrder.PrimaryAddress.City#) >
< cfset aPrimaryContactPostcode =(#mydoc.NetworkOrder.PrimaryAddress.PostalCode#) >
< cfset aPrimaryContactCounty =(#mydoc.NetworkOrder.PrimaryAddress.CountrySubdivision#) >
< cfset aPrimaryContactCountryCode =(#mydoc.NetworkOrder.PrimaryAddress.CountryCode#) >
< cfset aPrimaryContactCountry =(#mydoc.NetworkOrder.SecondaryAddress.Country#) >
< cfset aSecondaryContactName =(#mydoc.NetworkOrder.SecondaryAddress.ContactName#) >
< cfset aSecondaryAttentionOfName =(#mydoc.NetworkOrder.SecondaryAddress.AttentionOfName#) >
< cfset aSecondaryContactNumber =(#mydoc.NetworkOrder.SecondaryAddress.ContactNumber#) >
< cfset aSecondaryContactAddressLine1 =(#mydoc.NetworkOrder.SecondaryAddress.line1#) >
< cfset aSecondaryContactAddressLine2 =(#mydoc.NetworkOrder.SecondaryAddress.line2#) >
< cfset aSecondaryContactAddressLine3 =(#mydoc.NetworkOrder.SecondaryAddress.line3#) >
< cfset aSecondaryContactAddressLine4 =(#mydoc.NetworkOrder.SecondaryAddress.line4#) >
< cfset aSecondaryContactAddressLine5 =(#mydoc.NetworkOrder.SecondaryAddress.line5#) >
< cfset aSecondaryContactCity =(#mydoc.NetworkOrder.SecondaryAddress.City#) >
< cfset aSecondaryContactPostcode =(#mydoc.NetworkOrder.SecondaryAddress.PostalCode#) >
< cfset aSecondaryContactCounty =(#mydoc.NetworkOrder.SecondaryAddress.CountrySubdivision#) >
< cfset aSecondaryContactCountryCode =(#mydoc.NetworkOrder.SecondaryAddress.CountryCode#) >
< cfset aSecondaryContactCountry =(#mydoc.NetworkOrder.SecondaryAddress.Country#) >
Since you already have the XML parsed in a document, the easiest is to use xmlSearch(). Take a look at the doc, it is pretty easy to use. Something as simple as:
To the most complex as:
And in both cases:
Read the doc and google is your friend "coldfusion xmlsearch.
Tags: ColdFusion
Similar Questions
-
How to check if a table exists in the database or not?
People,
Hello. I use the server of Oracle 11 GR 1 material with Oracle Linux 5 database.
My instance of database is named HRCS90, which the user access Id is MyName, and his identification of user SYS system.
I have a few questions about user ID to access the PSRECDEL and PSROLEDEFN table in the HRCS90 database as below:
SQL > select * from PSRECDEL;
His output under the SYS user: table or view does not exist.
His output under user myName: no selected lines. This means that the table THAT PSRECDEL exists, and myName user can access.
SQL > select * from PSROLEDEFN;
His output under SYS and MyName: table or view does not exist.
My questions are:
How to check if a table really exists in the instance of database HRCS90 or not?
Thanks in advance.
If a table is present in the database, it must be present in DBA_OBJECTS. If he fell, he would be present in the TRASH. If he fell purged, it is not available in the database, Cant it confirm you this object is not in the database? See a little test here
SQL > CREATE TABLE TESTTAB (ID);
Table created.
SQL >
SQL > SELECT MASTER, OBJECT_NAME FROM DBA_OBJECTS WHERE OBJECT_NAME = 'TESTTAB.
OBJECT_NAME OWNER
------------------------------ ---------------------------------------------
SCOTT TESTTAB
SQL >
-Drop table (without purging. So now, it will be in the recyclebin)
SQL > DROP TABLE TESTTAB;
Deleted table.
SQL >
SQL > SELECT * FROM DBA_RECYCLEBIN WHERE ORIGINAL_NAME = "TESTTAB;
OBJECT_NAME ORIGINAL_NAME OWNER
------------------------------ ------------------------------ --------------
SCOTT BIN$ 8LKloIv3SYWA0WJ33GS + Aw == $0 TESTTAB
Now see this case when you use PURGE. If it won't move the table to the trash. First of all I am clear the existing dba_recyclebin to the user entries. Then I'm falling table using purge.
SQL > PURGE TABLESPACE USERS USER SCOTT.
Purged tablespace.
SQL >
SQL > SELECT * FROM DBA_RECYCLEBIN WHERE ORIGINAL_NAME = "TESTTAB;
no selected line
SQL > CREATE TABLE TESTTAB (ID);
Table created.
SQL >
SQL > SELECT MASTER, OBJECT_NAME FROM DBA_OBJECTS WHERE OBJECT_NAME = 'TESTTAB;
OBJECT_NAME OWNER
------ ----------
SYS TESTTAB
SQL > DROP TABLE TESTTAB PURGE;
Deleted table.
SQL > SELECT * FROM DBA_RECYCLEBIN WHERE ORIGINAL_NAME = "TESTTAB;
no selected line
SQL > SELECT MASTER, OBJECT_NAME FROM DBA_OBJECTS WHERE OBJECT_NAME = 'TESTTAB;
no selected line
Since there is no entry to both DBA_OBJECTS and DBA_RECYCLEBIN. So that means that the particular object is not in the database.
-
How to check if a string exists in varray or not
Hi all
How to check if a string exists in varray or not.
Version Details BANNER ---------------------------------------------------------------- Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product PL/SQL Release 10.2.0.1.0 - Production CORE 10.2.0.1.0 Production TNS for 32-bit Windows: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production
Thank youSQL> get test 1 DECLARE 2 TYPE dnames_var IS VARRAY(7) OF VARCHAR2(30); 3 dept_names dnames_var := dnames_var('Shipping','Sales','Finance','Payroll'); 4 BEGIN 5 if dept_names.exists('Shipping') 6 then 7 dbms_output.put_line('Exists ................'); 8 end if ; 9 /* DBMS_OUTPUT.PUT_LINE('dept_names has ' || dept_names.COUNT 10 || ' elements now'); 11 DBMS_OUTPUT.PUT_LINE('dept_names''s type can hold a maximum of ' 12 || dept_names.LIMIT || ' elements'); 13 DBMS_OUTPUT.PUT_LINE('The maximum number you can use with ' 14 || 'dept_names.EXTEND() is ' || (dept_names.LIMIT - dept_names.COUNT)); 15 */ 16* END; 17 18 / DECLARE * ERROR at line 1: ORA-06502: PL/SQL: numeric or value error: character to number conversion error ORA-06512: at line 5 SQL> Any help in this regard is appreciated ...
Prakash P
Published by: prakash on April 29, 2012 05:42EXISTS checks for the existence of an element, not a value. Since you're using VARRAY (btw, it is not recommended), your only choice is a loop through:
SQL> DECLARE 2 TYPE dnames_var IS VARRAY(7) OF VARCHAR2(30); 3 dept_names dnames_var := dnames_var('Shipping','Sales','Finance','Payroll'); 4 BEGIN 5 for i in 1..dept_names.count loop 6 if dept_names(i) = 'Shipping' 7 then 8 dbms_output.put_line('Exists ................'); 9 exit; 10 end if; 11 end loop; 12 END; 13 / Exists ................ PL/SQL procedure successfully completed. SQL>
If you use the nested table, you can use MEMBER, SUMBULTISET, MULTISET EXCEPT:
SQL> DECLARE 2 TYPE dnames_var IS TABLE OF VARCHAR2(30); 3 dept_names dnames_var := dnames_var('Shipping','Sales','Finance','Payroll'); 4 BEGIN 5 if 'Shipping' member of dept_names 6 then 7 dbms_output.put_line('Exists ................'); 8 end if ; 9 END; 10 / Exists ................ PL/SQL procedure successfully completed. SQL> DECLARE 2 TYPE dnames_var IS TABLE OF VARCHAR2(30); 3 dept_names dnames_var := dnames_var('Shipping','Sales','Finance','Payroll'); 4 BEGIN 5 if dnames_var('Shipping') submultiset dept_names 6 then 7 dbms_output.put_line('Exists ................'); 8 end if ; 9 END; 10 / Exists ................ PL/SQL procedure successfully completed. SQL> DECLARE 2 TYPE dnames_var IS TABLE OF VARCHAR2(30); 3 dept_names dnames_var := dnames_var('Shipping','Sales','Finance','Payroll'); 4 BEGIN 5 if dnames_var('Shipping') multiset except dept_names = dnames_var() 6 then 7 dbms_output.put_line('Exists ................'); 8 end if ; 9 END; 10 / Exists ................ PL/SQL procedure successfully completed. SQL>
SY.
-
My event.result may or may not return a node in the xml file. How can I avoid that TypeError: Error #1009: cannot access a property or method of a null object reference.
I have a very simple question. I want to take the value of
Event.Result.Item.nodeindex1.nodeindex2.Row.MyValue;
and assign it to a text field
mytextTi.text = event.result.item.nodeindex1.nodeindex2.row.myvalue;
But if a part of the tree is missing, which is also valid, so I get TypeError: Error #1009: cannot access a property or method of a null object reference.
I tried various solutions such as the following. Is there any simple way to do this?
If (event.result.item.nodeindex1.nodeindex2.row.myvalue! = undefined)-does not work
Unfortunately, one must test all levels to ensure that it is not null before the reference to it. You can take advantage of the short-circuit evaluation in tying together, for example
if (event.result.item && event.result.item.nodeindex1 && event.result.item.nodeindex1.nodeindex2 && event.result.item.nodeindex1.nodeindex2.row && event.result.item.nodeindex1.nodeindex2.row.myvalue) { // access the variable } else { // one of the XML nodes in the path is null }
Or you could stay away from her a little hacky and wrap the reference in a try/catch block.
-Tom
Flex SDK engineer
-
How to use resource element in the xml file in the workflow?
Good afternoon
In my workflow, I put a parameter of the attribute with the element of resource type and the value of the attribute is an xml file.
And I had a problem with xml files in my workflow, I would like to use the information in the xml file to store in the variable...
Example: in the xml file, I put some information about the number of VLAN ID, and in my script task, I would like to know how is used with myvariable.portgroup [0].spec.vlanId?
Best regards.
Like this:
var myXml = new XML(resource.getContentAsMimeAttachment().content);
You can then access your nodes like this:
myXml.node.subnode
Google for e4X to get the syntax complete.
-
How to import the xml file into bcc?
My input to atg file is xml containing assets of category or products.
I want the Scheduler to run to auto create a project and send an e-mail to the customer for approval.
When the client approves the xml file, and then run the Scheduler to get the data from the xml file into bcc.
I use: SingletonSchedulableService for this
Give me a direction for the same thing.
Thanks in advance.
I want to implement this in bcc.
What listener will listen to the authorization of the client for email (that contains the XML to import) we sent to him?
You will need to do a custom development to hang your workflow customized with incoming e-mail. To send notifications by mail electronic action is already there, and while creating his element within the ACC, you can specify a JSP page for the email template. You can view the rest of the relevant documents:
Oracle, Web ATG Commerce - Workflows
Oracle, ATG trade Web - action workflow items
I recommend you to consult the existing source of DeploymentEmailer in
\Publishing\samples\Java and see different types of DeploymentEvent and States can be used, based on your requirement in your custom component. See also these API javadocs for the process and the events of deployment available: DeploymentEvent (ATG Java API)
DeploymentServer (ATG Java API)
ATG has a component/atg/dynamo/service/POP3Service to retrieve messages from a POP3 e-mail server, but it is mainly used to detect the bounced email. Not too sure if it helps or adjustment in your case, but still you can go through all the details to know what is already there:
Bounced from Oracle ATG Web Commerce - E-mail
You can also check the event InboundEmail and API javadocs for InboundEmailMessage which are used in this function of rebound detection E-mail:
Oracle, ATG trade Web - InboundEmail event
InboundEmailMessage (ATG Java API)
Now based on all this, if you extend and customize a lot of things, that it would be little complex and tedious detect mail incoming approval based on its content and then advance your workflow. Another approach may be to put a URL in the e-mail template of your notification by e-mail that the approver will click and on the landing page, you can authenticate and advance your workflow to the needs.
-
Clone several nodes and appl_top shared using the XML file backup
Can I use work save file of application context to repeat the clones and avoid to perform following steps:
-Configure the node C (run '"perl adclonectx.pl sharedappltop contextfile = < context of Applications for the existing node file >' and ' perl-I < AU_TOP > / perl txkSOHM.pl"orders ")
If I work the previous clone XML, I would be able to use the same XMl file for re - clone without implement shared appltop and add a node step. Please, share your ideas.ma_apps wrote:
Can I use work save file of application context to repeat the clones and avoid to perform following steps:-Configure the node C (run '"perl adclonectx.pl sharedappltop contextfile =
' and 'perl - I /Perl txkSOHM.pl"orders) If I work the previous clone XML, I would be able to use the same XMl file for re - clone without implement shared appltop and add a node step. Please, share your ideas.
You should be able to use it. However, according to the Oracle docs support is to clone the main node and add more nodes by cloning the context files.
Cloning Oracle Applications Release 11i with rapid Clone [ID 230672.1]
Sharing the Application Tier file system in Oracle Applications Release 11i [ID 233428.1]Cloning Oracle Applications V12 with rapid Clone [ID 406982.1]
Share Application-level file system in Oracle E-Business Suite Release 12 [384248.1 ID]Thank you
Hussein -
How can I autorun script that will process an XML file at the opening?
I use image 11. I have a saved script that looks for the event Constants.FA_Note_PostOpenXML notification. When this event is raised, the script is supposed to examine the root element (so I change only the appropriate XML files), then make some changes to the file. Specifically, I want to be able to delete empty pages, remove the room for the heads side and correct table formatting (for example the left indent, whereby I can not directly access, apparently, in the rules of the EDD or R/W). The code snippet that starts to do the following work:
Notification (constants.FA_Note_PostOpenXML, true);
function {Notify (note, object, sparam, etriqu)
switch (note) {}
case Constants.FA_Note_PostOpenXML:
doTheWork();
break;
}
}
function doTheWork() {}
var doc, flow, root, elemName, mPageAttrib, topicElem, topicElemName, allAttribs;
doc = app. ActiveDoc;
flow = doc. MainFlowInDoc;
root = flow. HighestLevelElement; will always get something although unstructured document
While (root. ObjectValid()) {//only do something for structured documents
elemName = getElementName (root);
.. more code to do things...
}
}
I check then the element name root, and if it matches, I make a few changes. This code works fine when operating manually. But, when it is run as a recorded script, the app. ActiveDoc object is invalid, and there is no structure to edit. (I added the line if(!doc.) debug ObjectValid()) {alert ("invalid");} that is not included above.) It seems that the Constants.FA_Note_PostOpenXML event fires whenever the XML file opens, but BEFORE frame bed actually.
Does anyone have recommendations on how to get around this? Is there something else I could use instead of Constants.FA_Note_PostOpenXML? Is there another way to manipulate an XML file automatically when loading?
Thanks in advance
The notification event receives four settings: note, object, sparam and etriqu. For the event that you are using, the object must be the subject of document of the FrameMaker document being opened. Then, you should be able to use this:
doTheWork(object);
Make sure that you update your doTheWork function to receive the Doc object:
function doTheWork(doc) { var flow, root, elemName, mPageAttrib, topicElem, topicElemName, allAttribs; flow = doc.MainFlowInDoc; root = flow.HighestLevelElement; // will always get something even if unstructured document while(root.ObjectValid()) { //only do something for structured docs elemName = getElementName(root); ...more code to do stuff.... } }
-Rick
-
How can I save xml file n, run the xml file? Please help me
How can I save xml file n, run the xml file? Please help me
Hello
The question you have posted will be well suited in the MSDN forum. Click on the link below.
http://social.msdn.Microsoft.com/forums/en/categories/
In the meantime, I suggest you to return the item mentioned below.
How to use XML Notepad to create an XML document
-
OT: URGENT HELP!
Hi, I searched ALL the DirectX solutions and yet he's just not going to download! I just want to play Gmod but I need DirectX 11. Whenever I try to download DirectX it says 'a necessary .cab file for installation can not trust. Please check Cryptographic Services are enabled and the certificate file is valid. "I have my encryption services activated, but it STILL refuses to download. -HELP-
Hello
I'm sure that DX11 is already a part of win 8...
Maybe what you really need...
DirectX Runtime June 2010, which is an optional update that needs a lot of games.
Even my Lexmark printer requires... I'll include a link to the full installer...
This is a package to free extraction. It will extract after double-clicking it so be sure to note the location where extracted you\it.
Open the folder, and then double-click DXSETUP.
http://www.Microsoft.com/en-us/download/confirmation.aspx?ID=8109
-
Mixture of Photoshop mobile app. How can you save an edited photo in the same file as the original?
Hey there Mopi2!
Currently, there is no way to save your new image instead of the original image. For now, you need to manually delete the original. It is however a great request! Please share with the team by typing "give us feedback" in the app menu (tap on the app icon in the upper left corner of the screen while inside the app).
Let me know if that helps!
-Kathleen
-
How to search for text in all of the PDF files on a mobile device?
How to search for text in all of the PDF files on a mobile device?
Not possible on mobile devices.
-
Try to use the converter to push a VMX and VMDK existing in the environment file. Have you tried the Converter 4.3 and 5.0, continues to crash or delay. A 5.1 with ESXI 5.1 vCenter server hosts going conversion.
Take a look at this article. You can try Converter standalone 5.0.1 or 5.1 beta.
-
Image shows two NEF + JPEG, how do I know if I'm editing the RAW file?
In the library module, I have images that show the NEF + JPEG. When I click on the image and move the develop module, how can I know that I am editing the RAW file?
ILoveMyNikon wrote:
NEF + JPEG
Interpret as follows: raw file 'NAVE' a 'sidecar' jpeg disk file too, which was not imported, but is "follow-up." i.e. it is a NEF file.
The best way to develop the module file is raw or jpeg is to look at the cursor to temperature: temperature of jpeg is incremental, centered at 0, gross temperature is in degrees kelvin.
Rob
-
How to insert data in the XML file?
Hi guys,.
How to insert information into an XML file. I tell you, I have a CFM file with some questions to the user
When users submit this form within the form information is send in an XML file.
How can insert this information in the XML file?
When I don't have a DB?
Thank you
Kind regards
Fabiano Magno Pechibella
You must
- Read in the XML file
- Analyze the document in an XML (just one big struct) object
- Insert your XML code of the object where you need
- rewrite the XML file with your data now included
You can Google 'ColdFusion working with XML' and find hundreds of items to help you. Here's a beginning tutorial to help you get started:
Maybe you are looking for
-
Siri keeps saying "I don't see an app for that. You will need to download one. »
I just installed Sierra and tried to use Siri. I can't open any app on my Mac. No matter when I say something like, "FaceTime open" or "Open Pages," Siri comes back with something like "I don't see an app for that. "You will need to download a ' o
-
"This connection is Untrusted" - my PC clock is correct, but...
Earlier today, my PC clock set far in the future. I fixed it, don't think anything of it. Currently, he is correct. Now, I'm getting the "this connection is untrusted" on each site. If I change the clock from the PC to the INCORRECT date of tomorrow,
-
no need
-
boring data lost connectivity alerts
When I go into a building where my cell phone reception is weak, I have an alert 'data connectivity lost' even if I have a wifi connection works. I would like to disable this alert, but I can't find anywhere to do this.
-
Laptop HP G60t-500 - cannot find the DVD burner driver
Hello I upgraded my laptop G60t-500 for Windows 8. I had to reinstall some of the drivers in compatibility mode and overall, it works ok (thumping audio does not work, but I get audio with USB speakers) However, I just noticed that the DVD RW drive